You are here

uc_csv.install in Ubercart CSV 7.2

Same filename and directory in other branches
  1. 6.2 uc_csv.install

This defines our schema for the module

File

uc_csv.install
View source
<?php

/**
 * @file
 * This defines our schema for the module
 */

/**
 * Implements of hook_schema
 */
function uc_csv_schema() {
  $schema['uc_csv_reports'] = array(
    'description' => 'A table of configured reports',
    'fields' => array(
      'rid' => array(
        'description' => 'The export report key.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'report_name' => array(
        'description' => 'The name of the report',
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
      ),
      'last_exported' => array(
        'description' => 'The date of the last export',
        'mysql_type' => 'datetime',
        'type' => NULL,
      ),
      'last_order_id' => array(
        'description' => 'The last order id exported',
        'type' => 'int',
        'length' => 11,
        'not null' => TRUE,
      ),
      'shipping_address' => array(
        'description' => 'Include shipping report in export.',
        'type' => 'int',
        'length' => 1,
        'not null' => TRUE,
      ),
      'billing_address' => array(
        'description' => 'Include billing address in export',
        'type' => 'int',
        'length' => 1,
        'not null' => TRUE,
      ),
      'products' => array(
        'description' => 'Include products in export',
        'type' => 'int',
        'length' => 1,
        'not null' => TRUE,
      ),
      'orderby' => array(
        'description' => 'How the report is to be ordered',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'file_type' => array(
        'description' => 'The type of file to be exported',
        'type' => 'varchar',
        'length' => 8,
        'not null' => TRUE,
        'default' => 'csv',
      ),
      'statuses' => array(
        'description' => 'The order statuses to be included in this report',
        'type' => 'text',
        'size' => 'medium',
        'not null' => TRUE,
      ),
      'track' => array(
        'description' => 'Should this report track last exports. Boolean.',
        'type' => 'int',
        'length' => 1,
        'not null' => TRUE,
      ),
      'email_enable' => array(
        'description' => 'Are we emailing this report when generated',
        'type' => 'int',
        'length' => 1,
        'not null' => TRUE,
      ),
      'email_address' => array(
        'description' => 'Email address to send report to.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'rid',
    ),
  );
  return $schema;
}

/**
 * Add a field for the type of file to be exported with a report
 */
function uc_csv_update_7203() {
  db_add_field('uc_csv_reports', 'file_type', array(
    'description' => 'The type of file to be exported',
    'type' => 'varchar',
    'length' => 8,
    'not null' => TRUE,
    'default' => 'csv',
  ));
}

/**
 * Add a boolean field to determine if last order exported should be tracked per report
 */
function uc_csv_update_7204() {
  db_add_field('uc_csv_reports', 'track', array(
    'description' => 'Should this report track last exports. Boolean.',
    'type' => 'int',
    'length' => 1,
    'not null' => TRUE,
    'default' => '1',
  ));
}

/**
 * Add a status field. These are order statuses to be included in report exports.
 */
function uc_csv_update_7205() {
  db_add_field('uc_csv_reports', 'statuses', array(
    'description' => 'The order statuses to be included in this report',
    'type' => 'text',
    'not null' => TRUE,
    'size' => 'medium',
  ));
}

/**
 * Add fields to allow emailing of reports to specific users when reports are generated
 */
function uc_csv_update_7206() {
  $schema = uc_csv_schema();
  db_add_field('uc_csv_reports', 'report_email_enable', $schema['uc_csv_reports']['description']['email_enable']);
  db_add_field('uc_csv_reports', 'report_email_address', $schema['uc_csv_reports']['description']['email_address']);
}

Functions

Namesort descending Description
uc_csv_schema Implements of hook_schema
uc_csv_update_7203 Add a field for the type of file to be exported with a report
uc_csv_update_7204 Add a boolean field to determine if last order exported should be tracked per report
uc_csv_update_7205 Add a status field. These are order statuses to be included in report exports.
uc_csv_update_7206 Add fields to allow emailing of reports to specific users when reports are generated