/**
  * Create orocrm_magento_newsl_subscr table
  *
  * @param Schema $schema
  */
 protected function createOrocrmMagentoNewslSubscrTable(Schema $schema)
 {
     $table = $schema->createTable('orocrm_magento_newsl_subscr');
     $table->addColumn('id', 'integer', ['autoincrement' => true]);
     $table->addColumn('organization_id', 'integer', ['notnull' => false]);
     $table->addColumn('owner_id', 'integer', ['notnull' => false]);
     $table->addColumn('customer_id', 'integer', ['notnull' => false]);
     $table->addColumn('store_id', 'integer', ['notnull' => false]);
     $table->addColumn('channel_id', 'integer', ['notnull' => false]);
     $table->addColumn('data_channel_id', 'integer', ['notnull' => false]);
     $table->addColumn('email', 'string', ['notnull' => false, 'length' => 255]);
     $table->addColumn('change_status_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']);
     $table->addColumn('created_at', 'datetime', ['comment' => '(DC2Type:datetime)']);
     $table->addColumn('updated_at', 'datetime', ['comment' => '(DC2Type:datetime)']);
     $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]);
     $table->addColumn('confirm_code', 'string', ['notnull' => false, 'length' => 32]);
     $table->addIndex(['channel_id'], 'idx_7c8eaa72f5a1aa', []);
     $table->setPrimaryKey(['id']);
     $table->addIndex(['owner_id'], 'idx_7c8eaa7e3c61f9', []);
     $table->addIndex(['store_id'], 'idx_7c8eaab092a811', []);
     $table->addIndex(['organization_id'], 'idx_7c8eaa32c8a3de', []);
     $table->addIndex(['data_channel_id'], 'idx_7c8eaabdc09b73', []);
     $table->addUniqueIndex(['customer_id'], 'uniq_7c8eaa9395c3f3');
     $this->extendExtension->addEnumField($schema, $table, 'status', 'mage_subscr_status', false, false, ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
 }
Beispiel #2
0
 /**
  * Gets a table name for many-to-many relation
  *
  * @param string $activityTableName Activity entity table name. It is owning side of the association.
  * @param string $targetTableName   Target entity table name.
  *
  * @return string
  */
 public function getAssociationTableName($activityTableName, $targetTableName)
 {
     $sourceClassName = $this->extendExtension->getEntityClassByTableName($activityTableName);
     $targetClassName = $this->extendExtension->getEntityClassByTableName($targetTableName);
     $associationName = ExtendHelper::buildAssociationName($targetClassName, ActivityScope::ASSOCIATION_KIND);
     return $this->nameGenerator->generateManyToManyJoinTableName($sourceClassName, $associationName, $targetClassName);
 }
 public function testRunActivityLists()
 {
     $connection = $this->getMockBuilder('Doctrine\\DBAL\\Connection')->disableOriginalConstructor()->getMock();
     $connection->expects($this->any())->method('getDatabasePlatform')->will($this->returnValue(new MySqlPlatform()));
     $this->migrationQuery->setConnection($connection);
     $table = $this->schema->createTable('acme_test');
     $table->addColumn('id', 'integer', ['autoincrement' => true]);
     $table->setPrimaryKey(['id']);
     $table = $this->schema->createTable('oro_activity_list');
     $table->addColumn('id', 'integer', ['autoincrement' => true]);
     $table->setPrimaryKey(['id']);
     $extendOptionsManager = new ExtendOptionsManager();
     $entityMetadataHelper = $this->getMockBuilder('Oro\\Bundle\\EntityExtendBundle\\Migration\\EntityMetadataHelper')->disableOriginalConstructor()->getMock();
     $extendExtension = new ExtendExtension($extendOptionsManager, $entityMetadataHelper);
     $extendExtension->setNameGenerator($this->nameGenerator);
     $this->activityListExtension->setExtendExtension($extendExtension);
     $this->provider->expects($this->once())->method('getTargetEntityClasses')->willReturn(['Acme\\TestBundle\\Entity\\Test']);
     $this->metadataHelper->expects($this->once())->method('getTableNameByEntityClass')->with('Acme\\TestBundle\\Entity\\Test')->willReturn('acme_test');
     $entityMetadataHelper->expects($this->any())->method('getEntityClassByTableName')->willReturnCallback(function ($tableName) {
         if ($tableName === 'acme_test') {
             return 'Acme\\TestBundle\\Entity\\Test';
         }
         return 'Oro\\Bundle\\ActivityListBundle\\Entity\\ActivityList';
     });
     $log = $this->migrationQuery->getDescription();
     $this->assertEquals('CREATE TABLE oro_rel_c3990ba6784dd132527c89 (activitylist_id INT NOT NULL, test_id INT NOT NULL, ' . 'INDEX IDX_53682E3596EB1108 (activitylist_id), INDEX IDX_53682E351E5D0459 (test_id), ' . 'PRIMARY KEY(activitylist_id, test_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ' . 'ENGINE = InnoDB', $log[0]);
     $this->assertEquals('ALTER TABLE oro_rel_c3990ba6784dd132527c89 ADD CONSTRAINT FK_53682E3596EB1108 ' . 'FOREIGN KEY (activitylist_id) REFERENCES oro_activity_list (id) ON DELETE CASCADE', $log[1]);
     $this->assertEquals('ALTER TABLE oro_rel_c3990ba6784dd132527c89 ADD CONSTRAINT FK_53682E351E5D0459 FOREIGN KEY (test_id) ' . 'REFERENCES acme_test (id) ON DELETE CASCADE', $log[2]);
 }
 /**
  * @inheritdoc
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     if (!$this->isExecutedFromInstallCommand()) {
         return;
     }
     $this->extendExtension->addManyToOneRelation($schema, 'oro_embedded_form', 'branch', 'diamante_branch', 'name', ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM, 'is_extend' => true]]);
 }
 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $this->attachmentExtension->addFileRelation($schema, 'orocrm_partner', 'contract', [], 7);
     $this->attachmentExtension->addAttachmentAssociation($schema, 'orocrm_partner', ['image/*', 'application/pdf', 'application/zip', 'application/x-gzip', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'], 2);
     $this->noteExtension->addNoteAssociation($schema, 'orocrm_partner');
     $this->activityExtension->addActivityAssociation($schema, 'oro_email', 'orocrm_partner');
     $this->activityExtension->addActivityAssociation($schema, 'orocrm_partner_github_issue', 'orocrm_partner');
     $this->extendExtension->addEnumField($schema, $schema->getTable('orocrm_partner_github_issue'), 'status', 'github_issue_status', false, false, ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
 }
 /**
  * Add inheritance tables to target to show inherited activities
  *
  * @param Schema $schema
  * @param string $targetTableName Target entity table name
  * @param string $inheritanceTableName Inheritance entity table name
  * @param string[] $path Path of relations to target entity
  */
 public function addInheritanceTargets(Schema $schema, $targetTableName, $inheritanceTableName, $path)
 {
     $targetTable = $schema->getTable($targetTableName);
     $options = new OroOptions();
     $inheritance['target'] = $this->extendExtension->getEntityClassByTableName($inheritanceTableName);
     $inheritance['path'] = $path;
     $inheritances[] = $inheritance;
     $options->append('activity', 'inheritance_targets', $inheritances);
     $targetTable->addOption(OroOptions::KEY, $options);
 }
 /**
  * Adds the association between the target table and the visit table
  *
  * @param Schema $schema
  * @param string $targetTableName  Target entity table name
  * @param string $targetColumnName A column name is used to show related entity
  */
 public function addIdentifierAssociation(Schema $schema, $targetTableName, $targetColumnName = null)
 {
     $visitTable = $schema->getTable(self::VISIT_TABLE_NAME);
     $targetTable = $schema->getTable($targetTableName);
     if (empty($targetColumnName)) {
         $primaryKeyColumns = $targetTable->getPrimaryKeyColumns();
         $targetColumnName = array_shift($primaryKeyColumns);
     }
     $associationName = ExtendHelper::buildAssociationName($this->extendExtension->getEntityClassByTableName($targetTableName), self::ASSOCIATION_KIND);
     $this->extendExtension->addManyToOneRelation($schema, $visitTable, $associationName, $targetTable, $targetColumnName);
 }
 /**
  * Adds the association between the given table and the activity list table
  *
  * @param Schema $schema
  * @param string $targetTableName Target entity table name
  */
 public function addActivityListAssociation(Schema $schema, $targetTableName)
 {
     $targetTable = $schema->getTable($targetTableName);
     // Column names are used to show a title of target entity
     $targetTitleColumnNames = $targetTable->getPrimaryKeyColumns();
     // Column names are used to show detailed info about target entity
     $targetDetailedColumnNames = $targetTable->getPrimaryKeyColumns();
     // Column names are used to show target entity in a grid
     $targetGridColumnNames = $targetTable->getPrimaryKeyColumns();
     $associationName = ExtendHelper::buildAssociationName($this->extendExtension->getEntityClassByTableName($targetTableName), ActivityListEntityConfigDumperExtension::ASSOCIATION_KIND);
     $this->extendExtension->addManyToManyRelation($schema, $schema->getTable('oro_activity_list'), $associationName, $targetTable, $targetTitleColumnNames, $targetDetailedColumnNames, $targetGridColumnNames, ['extend' => ['without_default' => true]]);
 }
Beispiel #9
0
 /**
  * Adds the association between the target table and the note table
  *
  * @param Schema $schema
  * @param string $targetTableName  Target entity table name
  * @param string $targetColumnName A column name is used to show related entity
  */
 public function addNoteAssociation(Schema $schema, $targetTableName, $targetColumnName = null)
 {
     $noteTable = $schema->getTable(self::NOTE_TABLE_NAME);
     $targetTable = $schema->getTable($targetTableName);
     if (empty($targetColumnName)) {
         $primaryKeyColumns = $targetTable->getPrimaryKeyColumns();
         $targetColumnName = array_shift($primaryKeyColumns);
     }
     $options = new OroOptions();
     $options->set('note', 'enabled', true);
     $targetTable->addOption(OroOptions::KEY, $options);
     $associationName = ExtendHelper::buildAssociationName($this->extendExtension->getEntityClassByTableName($targetTableName));
     $this->extendExtension->addManyToOneRelation($schema, $noteTable, $associationName, $targetTable, $targetColumnName);
 }
 /**
  * Adds the association between the target table and the attachment table
  *
  * @param Schema   $schema
  * @param string   $targetTableName  Target entity table name
  * @param string[] $allowedMimeTypes The list of allowed MIME types
  * @param int      $maxFileSize      Max allowed file size in megabytes
  */
 public function addAttachmentAssociation(Schema $schema, $targetTableName, array $allowedMimeTypes = [], $maxFileSize = 1)
 {
     $noteTable = $schema->getTable(self::ATTACHMENT_ASSOCIATION_TABLE_NAME);
     $targetTable = $schema->getTable($targetTableName);
     $primaryKeyColumns = $targetTable->getPrimaryKeyColumns();
     $targetColumnName = array_shift($primaryKeyColumns);
     $options = new OroOptions();
     $options->set('attachment', 'enabled', true);
     $options->set('attachment', 'maxsize', $maxFileSize);
     $options->set('attachment', 'mimetypes', implode("\n", $allowedMimeTypes));
     $targetTable->addOption(OroOptions::KEY, $options);
     $associationName = ExtendHelper::buildAssociationName($this->extendExtension->getEntityClassByTableName($targetTableName));
     $this->extendExtension->addManyToOneRelation($schema, $noteTable, $associationName, $targetTable, $targetColumnName);
 }
 /**
  * Create custom entity tables
  *
  * @param Schema $schema
  *
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function createTestCustomEntityTables(Schema $schema)
 {
     $table1 = $this->extendExtension->createCustomEntityTable($schema, 'TestEntity1');
     $table1->addColumn('name', 'string', ['length' => 255, OroOptions::KEY => ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]]);
     $table2 = $this->extendExtension->createCustomEntityTable($schema, 'TestEntity2');
     $table2->addColumn('name', 'string', ['length' => 255, OroOptions::KEY => ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]]);
     // unidirectional many-to-one
     $this->extendExtension->addManyToOneRelation($schema, $table1, 'uniM2OTarget', $table2, 'name', ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
     // bidirectional many-to-one
     $this->extendExtension->addManyToOneRelation($schema, $table1, 'biM2OTarget', $table2, 'name', ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
     $this->extendExtension->addManyToOneInverseRelation($schema, $table1, 'biM2OTarget', $table2, 'biM2OOwners', ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
     // unidirectional many-to-many
     $this->extendExtension->addManyToManyRelation($schema, $table1, 'uniM2MTargets', $table2, ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
     // unidirectional many-to-many without default
     $this->extendExtension->addManyToManyRelation($schema, $table1, 'uniM2MNDTargets', $table2, ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM, 'without_default' => true]]);
     // bidirectional many-to-many
     $this->extendExtension->addManyToManyRelation($schema, $table1, 'biM2MTargets', $table2, ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
     $this->extendExtension->addManyToManyInverseRelation($schema, $table1, 'biM2MTargets', $table2, 'biM2MOwners', ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
     // bidirectional many-to-many without default
     $this->extendExtension->addManyToManyRelation($schema, $table1, 'biM2MNDTargets', $table2, ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM, 'without_default' => true]]);
     $this->extendExtension->addManyToManyInverseRelation($schema, $table1, 'biM2MNDTargets', $table2, 'biM2MNDOwners', ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
     // unidirectional one-to-many
     $this->extendExtension->addOneToManyRelation($schema, $table1, 'uniO2MTargets', $table2, ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
     // unidirectional one-to-many without default
     $this->extendExtension->addOneToManyRelation($schema, $table1, 'uniO2MNDTargets', $table2, ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM, 'without_default' => true]]);
     // bidirectional one-to-many
     $this->extendExtension->addOneToManyRelation($schema, $table1, 'biO2MTargets', $table2, ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
     $this->extendExtension->addOneToManyInverseRelation($schema, $table1, 'biO2MTargets', $table2, 'biO2MOwner', 'name', ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
     // bidirectional one-to-many without default
     $this->extendExtension->addOneToManyRelation($schema, $table1, 'biO2MNDTargets', $table2, ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM, 'without_default' => true]]);
     $this->extendExtension->addOneToManyInverseRelation($schema, $table1, 'biO2MNDTargets', $table2, 'biO2MNDOwner', 'name', ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
 }
 /**
  * @param QueryBag $queries
  * @param string   $entityTableName
  * @param string   $entityFieldName
  * @param int      $entityId
  * @param string[] $enumValueIds
  */
 protected function updateEnumSnapshot(QueryBag $queries, $entityTableName, $entityFieldName, $entityId, $enumValueIds)
 {
     $nameGenerator = $this->extendExtension->getNameGenerator();
     $query = sprintf('UPDATE %s SET %s = :snapshot WHERE id = :entityId', $entityTableName, $nameGenerator->generateMultiEnumSnapshotColumnName($entityFieldName));
     $params = ['entityId' => $entityId, 'snapshot' => $this->buildSnapshotValue($enumValueIds)];
     $types = ['entityId' => 'integer', 'enumValueId' => 'string'];
     $queries->addPostQuery(new ParametrizedSqlMigrationQuery($query, $params, $types));
 }
Beispiel #13
0
 /**
  * @param string $fieldName
  *
  * @return ParametrizedSqlMigrationQuery
  */
 protected function getDropEntityConfigManyToOneRelationQuery($fieldName)
 {
     $dropFieldIndexSql = 'DELETE FROM oro_entity_config_index_value' . ' WHERE entity_id IS NULL AND field_id IN (' . ' SELECT oecf.id FROM oro_entity_config_field AS oecf' . ' WHERE oecf.field_name = :field' . ' AND oecf.entity_id IN (' . ' SELECT oec.id' . ' FROM oro_entity_config AS oec' . ' WHERE oec.class_name = :class' . ' ))';
     $dropFieldSql = 'DELETE FROM oro_entity_config_field' . ' WHERE field_name = :field' . ' AND entity_id IN (' . ' SELECT id' . ' FROM oro_entity_config' . ' WHERE class_name = :class' . ' )';
     $taskClassName = $this->extendExtension->getEntityClassByTableName('orocrm_task');
     $query = new ParametrizedSqlMigrationQuery();
     $query->addSql($dropFieldIndexSql, ['field' => $fieldName, 'class' => $taskClassName], ['field' => 'string', 'class' => 'string']);
     $query->addSql($dropFieldSql, ['field' => $fieldName, 'class' => $taskClassName], ['field' => 'string', 'class' => 'string']);
     return $query;
 }
Beispiel #14
0
 /**
  * Adds the association between the given table and the table contains activity records
  *
  * The activity entity must be included in 'activity' group ('groups' attribute of 'grouping' scope)
  *
  * @param Schema $schema
  * @param string $activityTableName Activity entity table name. It is owning side of the association
  * @param string $targetTableName   Target entity table name
  * @param bool   $immutable         Set TRUE to prohibit disabling the activity association from UI
  */
 public function addActivityAssociation(Schema $schema, $activityTableName, $targetTableName, $immutable = false)
 {
     $targetTable = $schema->getTable($targetTableName);
     // Column names are used to show a title of target entity
     $targetTitleColumnNames = $targetTable->getPrimaryKeyColumns();
     // Column names are used to show detailed info about target entity
     $targetDetailedColumnNames = $targetTable->getPrimaryKeyColumns();
     // Column names are used to show target entity in a grid
     $targetGridColumnNames = $targetTable->getPrimaryKeyColumns();
     $activityClassName = $this->extendExtension->getEntityClassByTableName($activityTableName);
     $options = new OroOptions();
     $options->append('activity', 'activities', $activityClassName);
     if ($immutable) {
         $options->append('activity', 'immutable', $activityClassName);
     }
     $targetTable->addOption(OroOptions::KEY, $options);
     $associationName = ExtendHelper::buildAssociationName($this->extendExtension->getEntityClassByTableName($targetTableName), ActivityScope::ASSOCIATION_KIND);
     $this->extendExtension->addManyToManyRelation($schema, $activityTableName, $associationName, $targetTable, $targetTitleColumnNames, $targetDetailedColumnNames, $targetGridColumnNames, ['extend' => ['without_default' => true]]);
 }
Beispiel #15
0
 /**
  * Generate table orocrm_sales_lead
  *
  * @param Schema          $schema
  * @param ExtendExtension $extendExtension
  */
 public static function orocrmSalesLeadTable(Schema $schema, ExtendExtension $extendExtension)
 {
     /** Generate table orocrm_sales_lead **/
     $table = $schema->createTable('orocrm_sales_lead');
     $table->addColumn('id', 'integer', ['autoincrement' => true]);
     $table->addColumn('workflow_step_id', 'integer', ['notnull' => false]);
     $table->addColumn('workflow_item_id', 'integer', ['notnull' => false]);
     $table->addColumn('status_name', 'string', ['notnull' => false, 'length' => 32]);
     $table->addColumn('account_id', 'integer', ['notnull' => false]);
     $table->addColumn('user_owner_id', 'integer', ['notnull' => false]);
     $table->addColumn('contact_id', 'integer', ['notnull' => false]);
     $table->addColumn('address_id', 'integer', ['notnull' => false]);
     $table->addColumn('name', 'string', ['length' => 255]);
     $table->addColumn('name_prefix', 'string', ['notnull' => false, 'length' => 255]);
     $table->addColumn('first_name', 'string', ['length' => 255]);
     $table->addColumn('middle_name', 'string', ['notnull' => false, 'length' => 255]);
     $table->addColumn('last_name', 'string', ['length' => 255]);
     $table->addColumn('name_suffix', 'string', ['notnull' => false, 'length' => 255]);
     $table->addColumn('job_title', 'string', ['notnull' => false, 'length' => 255]);
     $table->addColumn('phone_number', 'string', ['notnull' => false, 'length' => 255]);
     $table->addColumn('email', 'string', ['notnull' => false, 'length' => 255]);
     $table->addColumn('company_name', 'string', ['notnull' => false, 'length' => 255]);
     $table->addColumn('website', 'string', ['notnull' => false, 'length' => 255]);
     $table->addColumn('number_of_employees', 'integer', ['notnull' => false]);
     $table->addColumn('industry', 'string', ['notnull' => false, 'length' => 255]);
     $table->addColumn('createdAt', 'datetime', []);
     $table->addColumn('updatedAt', 'datetime', ['notnull' => false]);
     $table->addColumn('notes', 'text', ['notnull' => false]);
     $extendExtension->addOptionSet($schema, $table, 'extend_source', ['extend' => ['set_expanded' => false]]);
     $table->setPrimaryKey(['id']);
     $table->addUniqueIndex(['workflow_item_id'], 'UNIQ_73DB46331023C4EE');
     $table->addIndex(['status_name'], 'IDX_73DB46336625D392', []);
     $table->addIndex(['contact_id'], 'IDX_73DB4633E7A1254A', []);
     $table->addIndex(['account_id'], 'IDX_73DB46339B6B5FBA', []);
     $table->addIndex(['address_id'], 'IDX_73DB4633F5B7AF75', []);
     $table->addIndex(['user_owner_id'], 'IDX_73DB46339EB185F9', []);
     $table->addIndex(['workflow_step_id'], 'IDX_73DB463371FE882C', []);
     /** End of generate table orocrm_sales_lead **/
 }
 /**
  * Create orob2b_customer table
  *
  * @param Schema $schema
  */
 protected function createOroB2BCustomerTable(Schema $schema)
 {
     $table = $schema->createTable(static::ORO_B2B_CUSTOMER_TABLE_NAME);
     $table->addColumn('id', 'integer', ['autoincrement' => true]);
     $table->addColumn('name', 'string', ['length' => 255]);
     $table->addColumn('parent_id', 'integer', ['notnull' => false]);
     $table->addColumn('group_id', 'integer', ['notnull' => false]);
     $table->addColumn('organization_id', 'integer', ['notnull' => false]);
     $table->setPrimaryKey(['id']);
     $table->addIndex(['name'], 'orob2b_customer_name_idx', []);
     $this->attachmentExtension->addAttachmentAssociation($schema, static::ORO_B2B_CUSTOMER_TABLE_NAME, ['image/*', 'application/pdf', 'application/zip', 'application/x-gzip', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation']);
     $this->noteExtension->addNoteAssociation($schema, static::ORO_B2B_CUSTOMER_TABLE_NAME);
     $this->extendExtension->addEnumField($schema, static::ORO_B2B_CUSTOMER_TABLE_NAME, 'internal_rating', Customer::INTERNAL_RATING_CODE);
 }
 /**
  * Create orocrm_sales_lead table
  *
  * @param Schema $schema
  */
 protected function createOrocrmSalesLeadTable(Schema $schema)
 {
     $table = $schema->createTable('orocrm_sales_lead');
     $table->addColumn('id', 'integer', ['autoincrement' => true]);
     $table->addColumn('address_id', 'integer', ['notnull' => false]);
     $table->addColumn('contact_id', 'integer', ['notnull' => false]);
     $table->addColumn('user_owner_id', 'integer', ['notnull' => false]);
     $table->addColumn('customer_id', 'integer', ['notnull' => false]);
     $table->addColumn('data_channel_id', 'integer', ['notnull' => false]);
     $table->addColumn('status_name', 'string', ['notnull' => false, 'length' => 32]);
     $table->addColumn('workflow_item_id', 'integer', ['notnull' => false]);
     $table->addColumn('workflow_step_id', 'integer', ['notnull' => false]);
     $table->addColumn('name', 'string', ['length' => 255]);
     $table->addColumn('name_prefix', 'string', ['notnull' => false, 'length' => 255]);
     $table->addColumn('first_name', 'string', ['length' => 255]);
     $table->addColumn('middle_name', 'string', ['notnull' => false, 'length' => 255]);
     $table->addColumn('last_name', 'string', ['length' => 255]);
     $table->addColumn('name_suffix', 'string', ['notnull' => false, 'length' => 255]);
     $table->addColumn('job_title', 'string', ['notnull' => false, 'length' => 255]);
     $table->addColumn('phone_number', 'string', ['notnull' => false, 'length' => 255]);
     $table->addColumn('email', 'string', ['notnull' => false, 'length' => 255]);
     $table->addColumn('company_name', 'string', ['notnull' => false, 'length' => 255]);
     $table->addColumn('website', 'string', ['notnull' => false, 'length' => 255]);
     $table->addColumn('number_of_employees', 'integer', ['notnull' => false]);
     $table->addColumn('industry', 'string', ['notnull' => false, 'length' => 255]);
     $table->addColumn('createdat', 'datetime', []);
     $table->addColumn('updatedat', 'datetime', ['notnull' => false]);
     $table->addColumn('notes', 'text', ['notnull' => false]);
     $this->extendExtension->addEnumField($schema, 'orocrm_sales_lead', 'source', 'lead_source');
     $this->extendExtension->addManyToOneRelation($schema, $table, 'campaign', 'orocrm_campaign', 'combined_name', ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
     $table->addIndex(['status_name'], 'idx_73db46336625d392', []);
     $table->addIndex(['user_owner_id'], 'idx_73db46339eb185f9', []);
     $table->addIndex(['customer_id'], 'IDX_73DB46339395C3F3', []);
     $table->addIndex(['data_channel_id'], 'IDX_73DB4633BDC09B73', []);
     $table->addIndex(['createdat'], 'lead_created_idx', []);
     $table->addIndex(['contact_id'], 'idx_73db4633e7a1254a', []);
     $table->setPrimaryKey(['id']);
     $table->addIndex(['workflow_step_id'], 'idx_73db463371fe882c', []);
     $table->addIndex(['address_id'], 'idx_73db4633f5b7af75', []);
     $table->addUniqueIndex(['workflow_item_id'], 'uniq_73db46331023c4ee');
 }
Beispiel #18
0
 /**
  * @param string   $sourceTableName
  * @param string   $targetTableName
  * @param string   $ownerColumnName
  * @param QueryBag $queries
  */
 public function assignActivities($sourceTableName, $targetTableName, $ownerColumnName, QueryBag $queries)
 {
     // prepare select email_id:contact_id sql
     $fromAndRecipients = '
         SELECT DISTINCT email_id, owner_id FROM (
             SELECT e.id as email_id, ea.{owner} as owner_id
             FROM oro_email_address ea
                 INNER JOIN oro_email e ON e.from_email_address_id = ea.id
             WHERE ea.{owner} IS NOT NULL
             UNION
             SELECT er.email_id as email_id, ea.{owner} as owner_id
             FROM oro_email_address ea
                 INNER JOIN oro_email_recipient er ON er.email_address_id = ea.id
             WHERE ea.{owner} IS NOT NULL
         ) as subq';
     $sourceClassName = $this->extendExtension->getEntityClassByTableName($sourceTableName);
     $targetClassName = $this->extendExtension->getEntityClassByTableName($targetTableName);
     $fromAndRecipients = str_replace('{owner}', $ownerColumnName, $fromAndRecipients);
     $associationName = ExtendHelper::buildAssociationName($targetClassName, ActivityScope::ASSOCIATION_KIND);
     $tableName = $this->nameGenerator->generateManyToManyJoinTableName($sourceClassName, $associationName, $targetClassName);
     $queries->addQuery(sprintf("INSERT INTO %s %s", $tableName, $fromAndRecipients));
 }
Beispiel #19
0
 /**
  * @inheritdoc
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $this->extendExtension->addManyToOneRelation($schema, 'orocrm_sales_lead', 'campaign', 'orocrm_campaign', 'combined_name', ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
 }
 /**
  * @return ExtendExtension
  */
 protected function getExtendExtension()
 {
     $result = new ExtendExtension($this->extendOptionsManager, $this->entityMetadataHelper);
     $result->setNameGenerator(new ExtendDbIdentifierNameGenerator());
     return $result;
 }
 /**
  * Add 'channel' to oro_tracking_website
  *
  * @param Schema $schema
  */
 protected function addChannelForeignKeyToTrackingWebsite(Schema $schema)
 {
     $this->extendExtension->addManyToOneRelation($schema, 'oro_tracking_website', 'channel', 'orocrm_channel', 'name', [ExtendOptionsManager::MODE_OPTION => ConfigModelManager::MODE_READONLY, 'entity' => ['label' => 'orocrm.channel.entity_label'], 'extend' => ['is_extend' => true, 'owner' => ExtendScope::OWNER_CUSTOM], 'datagrid' => ['is_visible' => false], 'form' => ['is_enabled' => true, 'form_type' => 'orocrm_channel_select_type', 'form_options' => ['tooltip' => 'orocrm.channel.tracking_website_channel_select.tooltip']], 'view' => ['is_displayable' => true], 'merge' => ['display' => false], 'dataaudit' => ['auditable' => false]]);
 }
Beispiel #22
0
 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $this->extendExtension->addEnumField($schema, 'orocrm_sales_lead', 'source', 'lead_source');
     $queries->addPostQuery(sprintf('UPDATE oro_entity_config_field SET mode=\'%s\' WHERE field_name=\'%s\'', ConfigModelManager::MODE_HIDDEN, 'extend_source'));
 }
Beispiel #23
0
 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $table = $schema->getTable('oro_tracking_website');
     $this->extendExtension->addManyToOneRelation($schema, $table, 'channel', 'orocrm_channel', 'name', [ExtendOptionsManager::MODE_OPTION => ConfigModel::MODE_READONLY, 'entity' => ['label' => 'orocrm.channel.entity_label'], 'extend' => ['is_extend' => true, 'owner' => ExtendScope::OWNER_CUSTOM], 'datagrid' => ['is_visible' => false], 'form' => ['is_enabled' => true, 'form_type' => 'orocrm_channel_select_type', 'form_options' => ['tooltip' => 'orocrm.channel.tracking_website_channel_select.tooltip']], 'view' => ['is_displayable' => true], 'merge' => ['display' => false], 'dataaudit' => ['auditable' => false]]);
 }
Beispiel #24
0
 /**
  * Gets an association column name for note relation
  *
  * @param string $targetTableName Target entity table name.
  *
  * @return string
  */
 public function getAssociationColumnName($targetTableName)
 {
     $associationName = ExtendHelper::buildAssociationName($this->extendExtension->getEntityClassByTableName($targetTableName));
     return $this->nameGenerator->generateManyToOneRelationColumnName($associationName);
 }
Beispiel #25
0
 /**
  * @param $schema
  */
 public function addExtendedFields($schema)
 {
     $this->extendExtension->addManyToOneRelation($schema, 'oro_embedded_form', 'dataChannel', 'orocrm_channel', 'name', ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM, 'is_extend' => true]]);
 }
Beispiel #26
0
 /**
  * @inheritdoc
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $table = $schema->getTable('oro_user_access_role');
     $table->addColumn('test_column', 'integer', []);
     $this->extendExtension->addManyToOneRelation($schema, $table, 'rel_m2o', 'oro_user', 'username', ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
 }
 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $this->extendExtension->addEnumField($schema, self::PRODUCT_TABLE_NAME, 'status', 'prod_status');
 }
 /**
  * Gets an activity list table name for many-to-many relation
  *
  * @param string $targetTableName Target entity table name.
  *
  * @return string
  */
 protected function getAssociationActivityListTableName($targetTableName)
 {
     $targetClassName = $this->extendExtension->getEntityClassByTableName($targetTableName);
     $associationName = ExtendHelper::buildAssociationName($targetClassName, ActivityListEntityConfigDumperExtension::ASSOCIATION_KIND);
     return $this->nameGenerator->generateManyToManyJoinTableName(ActivityListEntityConfigDumperExtension::ENTITY_CLASS, $associationName, $targetClassName);
 }
 /**
  * @param Schema $schema
  * @throws SchemaException
  */
 protected function updateProductTable(Schema $schema)
 {
     $this->extendExtension->addEnumField($schema, self::PRODUCT_TABLE_NAME, 'inventory_status', 'prod_inventory_status');
     $this->extendExtension->addEnumField($schema, self::PRODUCT_TABLE_NAME, 'visibility', 'prod_visibility');
 }
 /**
  * @inheritdoc
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $this->extendExtension->addManyToOneRelation($schema, 'oro_embedded_form', 'branch', 'diamante_branch', 'name', ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM, 'is_extend' => true]]);
 }