You are here

function pminvoice_install in Drupal PM (Project Management) 7

Implements hook_install().

File

pminvoice/pminvoice.install, line 10
Installation functions for PM Invoice.

Code

function pminvoice_install() {
  variable_set('node_options_pminvoice', array(
    'status',
  ));
  variable_set('node_options_pminvoiceitem', array(
    'status',
  ));
  variable_set('node_permissions_pminvoice', 0);
  variable_set('comment_pminvoice', 1);

  // Request date field.
  field_create_field(array(
    'type' => 'datetime',
    'field_name' => 'pminvoice_requestdate',
    'settings' => array(
      'granularity' => array(
        'year' => 'year',
        'month' => 'month',
        'day' => 'day',
        'hour' => 0,
        'minute' => 0,
        'second' => 0,
      ),
      'tz_handling' => '',
      'timezone_db' => '',
      'todate' => '',
    ),
    'cardinality' => '1',
  ));
  field_create_instance(array(
    'field_name' => 'pminvoice_requestdate',
    'bundle' => 'pminvoice',
    'label' => 'Request Date',
    'required' => 1,
    'entity_type' => 'node',
    'widget' => array(
      'weight' => '-17',
      'type' => 'date_text',
      'active' => 1,
    ),
    'settings' => array(
      'default_value' => 'now',
    ),
  ));

  // Due date field.
  field_create_field(array(
    'type' => 'datetime',
    'field_name' => 'pminvoice_duedate',
    'settings' => array(
      'granularity' => array(
        'year' => 'year',
        'month' => 'month',
        'day' => 'day',
        'hour' => 0,
        'minute' => 0,
        'second' => 0,
      ),
      'tz_handling' => '',
      'timezone_db' => '',
      'todate' => '',
    ),
    'cardinality' => '1',
  ));
  field_create_instance(array(
    'field_name' => 'pminvoice_duedate',
    'bundle' => 'pminvoice',
    'label' => 'Due Date',
    'required' => 1,
    'entity_type' => 'node',
    'widget' => array(
      'weight' => '-16',
      'type' => 'date_text',
      'active' => 1,
    ),
    'settings' => array(
      'default_value' => 'strtotime',
      'default_value_code' => '+28 days',
    ),
  ));

  // Payment date field.
  field_create_field(array(
    'type' => 'datetime',
    'field_name' => 'pminvoice_paymentdate',
    'settings' => array(
      'granularity' => array(
        'year' => 'year',
        'month' => 'month',
        'day' => 'day',
        'hour' => 0,
        'minute' => 0,
        'second' => 0,
      ),
      'tz_handling' => '',
      'timezone_db' => '',
      'todate' => '',
    ),
    'cardinality' => '1',
  ));
  field_create_instance(array(
    'field_name' => 'pminvoice_paymentdate',
    'bundle' => 'pminvoice',
    'label' => 'Payment Date',
    'required' => 0,
    'entity_type' => 'node',
    'widget' => array(
      'weight' => '-15',
      'type' => 'date_text',
      'active' => 1,
    ),
    'settings' => array(
      'default_value' => 'blank',
    ),
  ));
}