You are here

function merci_schema in MERCI (Manage Equipment Reservations, Checkout and Inventory) 6

Same name and namespace in other branches
  1. 6.2 merci.install \merci_schema()
  2. 7.2 merci.install \merci_schema()

Implementation of hook_schema().

File

./merci.install, line 193
merci Installer / Uninstaller

Code

function merci_schema() {
  $schema['merci_node_type'] = array(
    'description' => t('Stores booking-related information that applies to content types.'),
    'fields' => array(
      'type' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => t("Foreign key for {node_type}.type."),
      ),
      'type_setting' => array(
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => 'disabled',
        'description' => t("The MERCI type for the selected content type."),
      ),
      'max_hours_per_reservation' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("The maximum hours that the resource can be reserved for."),
      ),
      'allow_overnight' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("TRUE if the resource can be kept overnight."),
      ),
      'allow_weekends' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("TRUE if the resource can be kept over weekends."),
      ),
      'late_fee_per_hour' => array(
        'type' => 'float',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("Per hour fee if the resource is returned late."),
      ),
      'rate_per_hour' => array(
        'type' => 'float',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("Per hour fee for use of the resource."),
      ),
      'fee_free_hours' => array(
        'type' => 'float',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("Number of hours the item can be used before fees are charged."),
      ),
      'status' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("The status of the resource."),
      ),
      'spare_items' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("Number of spare items to leave unreserved for the resource."),
      ),
      'min_cancel_hours' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("Minimum number of hours a user can cancel a reservation for the item."),
      ),
      'autocheckout' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("TRUE if the resource is automatically checked out when Reservation starts."),
      ),
      'autocheckin' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("TRUE if the resource is automatically checked in when Reservation starts."),
      ),
      'selfcheckout' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("TRUE if the resource is managed by selfcheckout."),
      ),
      'grouping' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => FALSE,
        'description' => t("tid of MERCI Equiment Grouping vocabulary"),
      ),
    ),
    'primary key' => array(
      'type',
    ),
  );
  $schema['merci_reservation'] = array(
    'description' => t('Stores bookings reservations.'),
    'fields' => array(
      'nid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'description' => t("The reservations's associated nid."),
      ),
      'vid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'description' => t("The reservations's associated vid."),
      ),
      'status' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 1,
        'description' => t('Finalized bookings cannot have time conflicts with each other. Finalized availabilities must be obeyed.'),
      ),
    ),
    'primary key' => array(
      'nid',
      'vid',
    ),
  );
  $schema['merci_reservation_detail'] = array(
    'description' => t('Stores details on resources reserved.'),
    'fields' => array(
      'did' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => t('Unique ID for the reservation detail entry.'),
      ),
      'nid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'description' => t('Foreign key for {merci_reservation}.nid.'),
      ),
      'vid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'description' => t('Foreign key for {merci_reservation}.vid.'),
      ),
      'placeholder_nid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t('The nid for an associated reservation placeholder node for the reservation.'),
      ),
      'item_nid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t('The nid for an item node associated with the reservation placeholder node for the reservation.'),
      ),
      'item_status' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t('The status of the item associated in the item_nid column.'),
      ),
    ),
    'primary key' => array(
      'did',
    ),
    'indexes' => array(
      'nids' => array(
        'nid',
        'vid',
        'placeholder_nid',
        'item_nid',
      ),
      'item_status' => array(
        'item_status',
      ),
    ),
  );
  $schema['merci_bucket_node'] = array(
    'description' => t('Stores information on bookable bucket nodes.'),
    'fields' => array(
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => t("The bookable resource nid."),
      ),
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => t("The bookable resource vid."),
      ),
      'default_availability' => array(
        'type' => 'int',
        'not null' => TRUE,
        'size' => 'tiny',
        'default' => 0,
        'description' => t('Default availability of the resource.'),
      ),
      'late_fee_per_hour' => array(
        'type' => 'float',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("Per hour fee if the resource is returned late."),
      ),
      'rate_per_hour' => array(
        'type' => 'float',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("Per hour fee for use of the resource."),
      ),
      'fee_free_hours' => array(
        'type' => 'float',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("Number of hours the item can be used before fees are charged."),
      ),
      'min_cancel_hours' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("Minimum number of hours a user can cancel a reservation for the item."),
      ),
      'autocheckout' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("TRUE if the resource is automatically checked out when Reservation starts."),
      ),
      'autocheckin' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("TRUE if the resource is automatically checked in when Reservation starts."),
      ),
      'selfcheckout' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("TRUE if the resource is managed by selfcheckout."),
      ),
      'sub_type' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("The subtype of bucket node, either item or reservation."),
      ),
    ),
    'primary key' => array(
      'nid',
      'vid',
    ),
  );
  $schema['merci_resource_node'] = array(
    'description' => t('Stores information on bookable resource nodes.'),
    'fields' => array(
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => t("The bookable resource nid."),
      ),
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => t("The bookable resource vid."),
      ),
      'default_availability' => array(
        'type' => 'int',
        'not null' => TRUE,
        'size' => 'tiny',
        'default' => 0,
        'description' => t('Default availability of the item .'),
      ),
      'late_fee_per_hour' => array(
        'type' => 'float',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("Per hour fee if the resource is returned late."),
      ),
      'rate_per_hour' => array(
        'type' => 'float',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("Per hour fee for use of the resource."),
      ),
      'fee_free_hours' => array(
        'type' => 'float',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("Number of hours the item can be used before fees are charged."),
      ),
      'min_cancel_hours' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("Minimum number of hours a user can cancel a reservation for the item."),
      ),
      'autocheckout' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("TRUE if the resource is automatically checked out when Reservation starts."),
      ),
      'autocheckin' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("TRUE if the resource is automatically checked in when Reservation starts."),
      ),
      'selfcheckout' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("TRUE if the resource is managed by selfcheckout."),
      ),
      'sub_type' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("The subtype of resource node, either item or reservation."),
      ),
    ),
    'primary key' => array(
      'nid',
      'vid',
    ),
  );
  return $schema;
}