You are here

function bat_event_generate_minute_schema_fields in Booking and Availability Management Tools for Drupal 7

Same name and namespace in other branches
  1. 8 modules/bat_event/bat_event.module \bat_event_generate_minute_schema_fields()

Creates the necessary minute schema fields.

Return value

array

1 call to bat_event_generate_minute_schema_fields()
bat_event_create_event_type_schema in modules/bat_event/bat_event.module
Create 6 tables for store events of type $machine_name.

File

modules/bat_event/bat_event.module, line 2263
Manage Events - Events store the EventValue of a Unit over a period of time.

Code

function bat_event_generate_minute_schema_fields() {
  $fields = array(
    'unit_id' => array(
      'description' => 'Identifier for a unit.',
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
    ),
    'year' => array(
      'description' => 'The calendar year for which this availability row is relevant',
      'type' => 'int',
      'not null' => TRUE,
      'default' => '0',
    ),
    'month' => array(
      'description' => 'The month for which this availability row is relevant',
      'type' => 'int',
      'not null' => TRUE,
      'default' => '0',
    ),
    'day' => array(
      'description' => 'The day for which this availability row is relevant',
      'type' => 'int',
      'not null' => TRUE,
      'default' => '0',
    ),
    'hour' => array(
      'description' => 'The hour for which this availability row is relevant',
      'type' => 'int',
      'not null' => TRUE,
      'default' => '0',
    ),
  );
  for ($i = 0; $i <= 59; $i++) {

    // PHP has no clean way to get the minutes without leading zeros so setting table
    // fields names to contain the leading zeros to save strangeness in code elsewhere.
    if ($i <= 9) {
      $m = '0' . $i;
    }
    else {
      $m = $i;
    }
    $fields['m' . $m] = array(
      'description' => 'M' . $m,
      'type' => 'int',
      'not null' => TRUE,
      'default' => '0',
    );
  }
  return $fields;
}