You are here

function views_gantt_plugin_style_gantt::add_task in Views Gantt 7.2

Same name and namespace in other branches
  1. 7 views_gantt_plugin_style_gantt.inc \views_gantt_plugin_style_gantt::add_task()
3 calls to views_gantt_plugin_style_gantt::add_task()
views_gantt_plugin_style_gantt::get_project in ./views_gantt_plugin_style_gantt.inc
views_gantt_plugin_style_gantt::load_task_from_node in ./views_gantt_plugin_style_gantt.inc
views_gantt_plugin_style_gantt::render in ./views_gantt_plugin_style_gantt.inc
Render the given style.

File

./views_gantt_plugin_style_gantt.inc, line 633
Contains the list style plugin.

Class

views_gantt_plugin_style_gantt
Style plugin to render Gantt charts.

Code

function add_task($data, $type = 'view', $row_key = NULL) {
  switch ($type) {
    case 'view':
      $method = 'views_gantt_get_field_value';
      $task_id = $this
        ->{$method}($data, 'id_field');
      break;
    case 'node':
      $method = 'views_gantt_get_node_field_value';
      $task_id = $data->nid;
      break;
    default:
      return;
  }
  $keys = array(
    'name' => 'name_field',
    'est' => 'date_field',
    'end_date' => 'end_date_field',
    'percentcompleted' => 'progress_field',
    'predecessortasks' => 'predecessor_id_field',
    'parent_id' => 'parent_id_field',
  );
  $task = array(
    'columns' => array(),
  );

  // Add fields for chart
  foreach ($keys as $key => $field) {
    $task[$key] = $this
      ->{$method}($data, $field);
  }

  // Add columns
  foreach ($this->columns as $key => $value) {
    if ($this->options['progress_field'] == $key) {
      $task['columns']['progress'] = (int) $task['percentcompleted'] . '%';
      continue;
    }
    switch ($type) {
      case 'view':
        $this->options[$key] = $key;
        break;
      case 'node':
        $this->options_node[$key] = $key;
        break;
    }
    $task['columns'][$key] = $this
      ->{$method}($data, $key);
  }
  $this->tasks[$task_id] = $task + array(
    'childtasks' => array(),
  );
  return $task_id;
}