⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Error thrown in read mode



John Ophof

John Ophof
  • profile picture
  • Member

Posted 11 February 2015 - 13:28 PM

Hi,

 

The issue here under was solved by adding a function to the library.

I added this code and the issue was solved:

  private $read_fields_checked = false;
  protected $unset_read_fields = null;

  protected function get_true_false_readonly_input($field_info, $value) {
    $this->set_css($this->default_css_path . '/jquery_plugins/uniform/uniform.default.css');
    $this->set_js_lib($this->default_javascript_path . '/jquery_plugins/jquery.uniform.min.js');
    $this->set_js_config($this->default_javascript_path . '/jquery_plugins/config/jquery.uniform.config.js');

    $value_is_null = empty($value) && $value !== '0' && $value !== 0 ? true : false;

    $input = "<div class='pretty-radio-buttons'>";

    $true_string = is_array($field_info->extras) && array_key_exists(1, $field_info->extras) ? $field_info->extras[1] : $this->default_true_false_text[1];
    $checked = $value === '1' || ($value_is_null && $field_info->default === '1') ? "checked = 'checked'" : "";
    $input .= "<label><input id='field-{$field_info->name}-true' class='radio-uniform' readonly='readonly' type='radio' name='{$field_info->name}' value='1' $checked /> " . $true_string . "</label> ";

    $false_string = is_array($field_info->extras) && array_key_exists(0, $field_info->extras) ? $field_info->extras[0] : $this->default_true_false_text[0];
    $checked = $value === '0' || ($value_is_null && $field_info->default === '0') ? "checked = 'checked'" : "";
    $input .= "<label><input id='field-{$field_info->name}-false' class='radio-uniform' readonly='readonly' type='radio' name='{$field_info->name}' value='0' $checked /> " . $false_string . "</label>";

    $input .= "</div>";

    return $input;
  }
 

 

On irc they called grocerycrud obscure because of a small number of people using it. I hope this post got valuable response.

 

Here is my template. Created by a class generator.

Ready for sprint is acting as a boolean. 1 is true 0 is false.

Working with 1.5 version but extended for the missing set_read_field this for creating hyperlinks to other forms. The joins are generated by the class generator based on the DB relations (based on DB standards/conventions).

 

See also one other struggle here:

/topic/2918-relation-n-n/

 

Another thing I would like the achieve is attach a hyperlink in a WYSIWYG field so it would be possible to create a hyperlink to another form.

 

In read mode I got this error:

 

Fatal error: Call to undefined method Grocery_CRUD::get_true_false_readonly_input() in /Volumes/WDMobile/htdocs/ezbuild30/application/ezbuild/libraries/Grocery_CRUD.php on line 3074

A PHP Error was encountered

Severity: Error

Message: Call to undefined method Grocery_CRUD::get_true_false_readonly_input()

Filename: libraries/Grocery_CRUD.php

Line Number: 3074

Backtrace:

 

This is the table definition of User_story:

 

CREATE TABLE `user_story` (
  `user_storyID` int(11) NOT NULL AUTO_INCREMENT,
  `high_level_requirementID` int(11) DEFAULT NULL,
  `requirement` mediumtext,
  `product_backlog_itemID` int(11) DEFAULT NULL,
  `ready_for_sprint` tinyint(4) DEFAULT NULL,
  `sprint_backlogID` int(1) DEFAULT NULL,
  `name` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`user_storyID`),
  KEY `fk_user_story_high_level_requirement1_idx` (`high_level_requirementID`),
  KEY `fk_user_story_product_backlog_item1_idx` (`product_backlog_itemID`),
  KEY `fk_user_story_sprint_backlog1_idx` (`sprint_backlogID`),
  CONSTRAINT `fk_user_story_high_level_requirement1` FOREIGN KEY (`high_level_requirementID`) REFERENCES `high_level_requirement` (`high_level_requirementID`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_user_story_product_backlog_item1` FOREIGN KEY (`product_backlog_itemID`) REFERENCES `product_backlog_item` (`product_backlog_itemID`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_user_story_sprint_backlog1` FOREIGN KEY (`sprint_backlogID`) REFERENCES `sprint_backlog` (`sprint_backlogID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
 

 

<?php

// form validation greater than example http://stackoverflow.com/questions/1996197/codeigniter-validation-how-to-limit-numerical-value
require_once("MY_Ezbuild.php");

if (!defined('BASEPATH'))
  exit('No direct script access allowed');

class User_story extends MY_Ezbuild {

  function __construct() {
    parent::__construct();

    /* Standard Libraries of codeigniter are required */
    $this->load->database("local_scrumba");
    $this->load->driver("session");
    switch ($_SERVER['SERVER_NAME']) {
      case DEV_SERVER_NAME:
// development server
        $config['base_url'] = "http://127.0.0.1/ezbuild30";
        $this->scrumbadb = $this->load->database("local_scrumba", true);
        $this->dbname = "scrumba";
        break;
      case STAGING_SERVER_NAME:
// staging server
        $this->dbname = "web453_cafonline";
        $config['base_url'] = "http://cafonline.touchingservices.nl";
        $this->scrumbadb = $this->load->database("cloud_scrumba", true);
        break;
      default:
// live server
        $config['base_url'] = "http://www.happyaway.nl";
        break;
    }

    //$this->load->database();
    $this->load->helper('url');
    /* ------------------ */
    $this->load->library('grocery_CRUD');
    $this->delimiter = "- ";
    $this->form_validation->set_message('required', '* required');
    $this->session->set_userdata('language', 'EN');
    $this->lan = $this->session->userdata('language');
  }

  private function _findtable($name) {
    $sql = "select `m_tableID`, `name` from `m_table` where `m_table`.`name` = ? and is_view = ?";
    $query = $this->scrumbadb->query($sql, array($name, 0));
    foreach ($query->result() as $row) {
      return $row;
    }
  }

  private function _findtablebyID($ID) {
    $sql = "select `m_tableID`, `name` from `m_table` where `m_table`.`m_tableID` = ? and is_view = ?";
    $query = $this->scrumbadb->query($sql, array($ID, 0));
    foreach ($query->result() as $row) {
      return $row;
    }
  }

  private function _subject_from_meta($language, $table) {
    $default_subject = ucfirst($table->name);
    $default_subject = str_replace("_", " ", $default_subject);
    $sql = "select `name` from `m_table_subject` `mts`
            where `mts`.`language` = ? and `mts`.`m_tableID` = ?";

    $query = $this->scrumbadb->query($sql, Array($language, $table->m_tableID));
    foreach ($query->result() as $row) {
      $subject = $row->name;
    }
    if (!isset($subject)) {
      $subject = $default_subject;
    }
    return ($subject);
  }

  private function _create_hyperlinks($sql, $primary_key, $table, $fields) {
    $query = $this->scrumbadb->query($sql, array($primary_key));
    $str = "";
    $keyfield_hyper = $table . "ID";
    foreach ($query->result() as $row) {
      $url = site_url("sprint/$table/read/" . $row->$keyfield_hyper);
      $hyper = "";
      foreach ($fields as $field) {
        if (isset($row->$field)) {
          if ($hyper != "") {
            $hyper .= " - " . $row->$field;
          } else {
            $hyper .= $row->$field;
          }
        }
      }
      $str .= "<a href='" . $url . "'>" . $hyper . "</a><br/>";
    }
    return $str;
  }

  private function _get_table_subject($tableID) {
    if (is_numeric($tableID)) {
      $table = $this->_findtablebyID($tableID);
    } else {
      $table = $this->_findtable($tableID);
    }
    $subject = "";
    if (isset($table)) {
      if ($this->lan == "NL") {
        $subject = $this->_subject_from_meta("NL", $table);
      } else if ($this->lan == "EN") {
        $subject = $this->_subject_from_meta("EN", $table);
      } else if ($this->lan == "FR") {
        $subject = $this->_subject_from_meta("FR", $table);
      } else if ($this->lan == "DE") {
        $subject = $this->_subject_from_meta("DE", $table);
      }
    }
    return ($subject);
  }

  private function _lookup_fields($tableID, $prefix) {
    $sql = "select `name` from m_field where m_tableID = $tableID and lookup_sequence <> 0 and is_AIfield = 0 order by lookup_sequence";
    $string = "";
    $query = $this->scrumbadb->query($sql, array($tableID));
    foreach ($query->result() as $row) {
      $string .= $prefix . "." . $row->name . ",";
    }
    if ($string == "") {
      $sql = "select `name` from m_field where m_tableID = ? and (`name` = 'name' or `mysql_type` like 'varchar%')";
      $query = $this->scrumbadb->query($sql, array($tableID));
      foreach ($query->result() as $row) {
        if ($row->name == "name") { // preference for name field
          $string = $prefix . "." . $row->name . ",";
          break;
        } else {
          $string = $prefix . "." . $row->name . ",";
        }
      }
    }
    if ($string != "") {
      $string = rtrim($string, ",");
    } else {
      $this->log("No lookup fields found tableID = $tableID");
    }
    return ($string);
  }

  function _init_stack($table1ID, $table2ID) {
    $this->joinstack = array();
    $sql = "select mr.m_relationID, mr.table1ID, mr.table2ID, mr.cardinality "
            . " from m_relation mr where (mr.table1ID = ?) or (mr.table2ID = ?)";
    $query = $this->scrumbadb->query($sql, array($table1ID, $table1ID));
    // what tables are linked to $table1ID
    $finished = false;
    foreach ($query->result() as $row) {
      if ((($row->table2ID == $table2ID) && ($row->table1ID == $table1ID)) ||
              (($row->table2ID == $table1ID) && ($row->table1ID == $table2ID))) {
        $entry = new stdClass();
        $entry->table1ID = $table1ID;
        $entry->table2ID = $table2ID;
        $entry->valid = true;
        $finished = true;
      } else {
        $entry = new stdClass();
        $entry->table1ID = $row->table1ID;
        $entry->table2ID = $row->table2ID;
        $entry->valid = false;
      }
      array_push($this->joinstack, $entry);
    }
    return ($finished);
  }

  function _add_2_stack($table1ID, $table2ID) {
    $found = false;
    foreach ($this->joinstack as $entry) {
      if (( ($entry->table1ID == $table1ID ) && ($entry->table2ID == $table2ID ) ) ||
              ( ($entry->table2ID == $table1ID ) && ($entry->table1ID == $table2ID ) )) {
        $found = true;
      }
    }
    if (!$found) {
      $entry = new stdClass();
      $entry->table1ID = $table1ID;
      $entry->table2ID = $table2ID;
      $entry->valid = false;
      array_push($this->joinstack, $entry);
      return true;
    } else {
      return false;
    }
  }

  function _topstack() {
    $count = count($this->joinstack);
    if ($count > 0) {
      return ( $this->joinstack[$count - 1]);
    }
  }

  /*
   * Recursive routine to create the joins
   */

  function _process_stack() {
    $top_stack = $this->_topstack();
    if (isset($top_stack)) {
      $sql = "select mr.m_relationID, mr.table1ID, mr.table2ID, mr.cardinality "
              . " from m_relation mr where (mr.table1ID = ?) or (mr.table2ID = ?)";
      $debug = str_replace("?", $top_stack->table2ID, $sql);
      $query = $this->scrumbadb->query($sql, array($top_stack->table2ID, $top_stack->table2ID));
      $ladd = false;
      $finished = false;
      foreach ($query->result() as $row) {
        if (($row->table1ID == $this->endtable->m_tableID) || ($row->table2ID == $this->endtable->m_tableID)) {
          $finished = true;
          $top_stack->valid = true;
          if ($row->table1ID == $top_stack->table2ID) {
            $ladd = $this->_add_2_stack($row->table2ID, $top_stack->table2ID);
          } else if ($row->table2ID == $top_stack->table2ID) {
            $ladd = $this->_add_2_stack($row->table1ID, $top_stack->table2ID);
          }
          if ($ladd) {
            $top_stack = $this->_topstack();
            $top_stack->valid = true;
          }
          break;
        } else if ($row->table1ID == $top_stack->table2ID) {
          $ladd = $this->_add_2_stack($row->table1ID, $row->table2ID);
        }
      }
      if ($finished) {
        return (true);
      } else {
        if (!$ladd) {
          array_pop($this->joinstack);
        }
        $finished = $this->_process_stack();
        if ($finished) {
          return (true);
        }
      }
    } else {
      return (true);
    }
  }

  /*
   * Process the stack and build the join
   */

  function _makejoin() {
    $size = count($this->joinstack);
    $sqljoin = "";
    $stop = false;
    $couple_table_info = null;
    $couple_table = null;
    while (!$stop) {
      $top_stack = $this->_topstack();
      if (isset($top_stack)) {
        if ($this->endtable->m_tableID == $top_stack->table1ID) {
          $couple_table = $top_stack->table2ID;
        } else if ($this->endtable->m_tableID == $top_stack->table2ID) {
          $couple_table = $top_stack->table1ID;
        } else if ($couple_table == $top_stack->table1ID) {
          $couple_table = $top_stack->table2ID;
        } else if ($couple_table == $top_stack->table2ID) {
          $couple_table = $top_stack->table1ID;
        } else {
          $couple_table = $top_stack->table1ID;
        }
        $couple_table_prev = $couple_table_info;
        $couple_table_info = $this->_findtablebyID($couple_table);
        if ($sqljoin == "") {
          $sqljoin .= " inner join " . $couple_table_info->name . " on " . $couple_table_info->name . "." .
                  $this->endtable->name . "ID = " . $this->endtable->name . "." . $this->endtable->name . "ID";
        } else if (isset($couple_table_prev)) {
          $sqljoin .= " inner join " . $couple_table_info->name . " on " . $couple_table_info->name . "." .
                  $couple_table_info->name . "ID = " . $couple_table_prev->name . "." . $couple_table_info->name . "ID";
        }
        array_pop($this->joinstack);
        $stop = ($couple_table == $this->begintable->m_tableID);
      } else {
        $stop = true; // stack is empty
      }
    }
    if ($sqljoin != "") {
      $fields = $this->_lookup_fields($this->endtable->m_tableID, $this->endtable->name);
      if ($fields != "") {
        $fields = $this->endtable->name . "." . $this->endtable->name . "ID," . $fields;
        $sqljoin = "select distinct $fields from " . $this->endtable->name . $sqljoin .
                " and " . $this->begintable->name . "." . $this->begintable->name . "ID = ?";
      }
    }
    return ($sqljoin);
  }

  function _create_join_extra(
  $source_table, $lookup_table, $keyfield) {
    $table1 = $this->_findtable($source_table);
    $table2 = $this->_findtable($lookup_table);
    $this->begintable = $table1;
    $this->endtable = $table2;
    $this->keyfield = $keyfield;

    $finished = $this->_init_stack($table1->m_tableID, $table2->m_tableID);
    if (!$finished) {
      $finished = $this->_process_stack();
      if ($finished) {
        $sql = $this->_makejoin();
      }
    } else {
      $sql = $this->_makejoin(); // simple join
    }
    return ($sql);
  }

  private function _create_join($source_table, $field_name, $lookup_table, $lookup_tableID) {
    if ($lookup_tableID != -1) {
      $table1 = rtrim($field_name, "ID"); // scrum_master
      $table1ID = $this->_findtable($table1);
      if (isset($table1ID)) {
        $sql = "select cardinality from m_relation where (table1ID = ? and table2ID = ?) or (table1ID = ? and table2ID = ?) ";
        $fields = $this->_lookup_fields($lookup_tableID, $lookup_table);
        $query = $this->scrumbadb->query($sql, array($table1ID, $lookup_tableID, $lookup_tableID, $table1ID));
        foreach ($query->result() as $row) {
          $sql_join = " inner join $table1 on $table1.$field_name = $source_table.$field_name
    inner join $lookup_table on $lookup_table.$lookup_table" . "ID" . " = $table1.$lookup_table" . "ID" .
                  " and $source_table.$field_name = ?";
          $sql = "select distinct $fields from $source_table $sql_join";
          $this->cb_lines[] = "//$sql";
          return ($sql);
        }
      } else {
        return;
      }
    } else {
      // so a directlink must be an ID field of a table
      $table1 = rtrim($field_name, "ID"); // scrum_master
      $table1ID = $this->_findtable($table1);
      $fields = $this->_lookup_fields($table1ID);
      $sql_join = " inner join $table1 on $table1.$field_name = $source_table.$fieldname
    inner join $lookup_table on $lookup_table.$field_name" . "ID" . " = $source_table.$lookup_table" . "ID" .
              " and $source_table.$fieldname = ?";
      $sql = "select distinct $fields from $source_table $sql_join";
      $this->cb_lines[] = "//$sql";
      return ($sql);
    }
  }

  public function _scrumba_output($output = null) {
    $this->load->view('scrumba.php', $output);
  }

  public function index() {
    $crud = new grocery_CRUD();

    $crud->set_theme('datatables');
    if ($this->lan == "NL") {
      $subject = "User story";
    } else if ($this->lan == "EN") {
      $subject = "User story";
    } else if ($this->lan == "FR") {
      $subject = "User story";
    } else if ($this->lan == "DE") {
      $subject = "User story";
    }
    $crud->set_subject($subject);
    $crud->callback_field('high_level_requirementID_@add', array($this, '_add_high_level_requirement_hyperlink'));
    $subject = $this->_get_table_subject(10);
    $crud->display_as('high_level_requirementID_@add', 'Add ' . $subject);
    $crud->callback_field('product_backlog_itemID_@add', array($this, '_add_product_backlog_item_hyperlink'));
    $subject = $this->_get_table_subject(17);
    $crud->display_as('product_backlog_itemID_@add', 'Add ' . $subject);
    $crud->callback_field('sprint_backlogID_@add', array($this, '_add_sprint_backlog_hyperlink'));
    $subject = $this->_get_table_subject(25);
    $crud->display_as('sprint_backlogID_@add', 'Add ' . $subject);
    $crud->fields('high_level_requirementID', 'high_level_requirementID_@add', 'requirement', 'product_backlog_itemID', 'product_backlog_itemID_@add', 'ready_for_sprint', 'sprint_backlogID', 'sprint_backlogID_@add', 'name');
    $crud->set_table('user_story');
    $crud->columns('high_level_requirementID', 'requirement', 'product_backlog_itemID', 'ready_for_sprint', 'sprint_backlogID', 'name');
    $crud->callback_column('high_level_requirementID', array($this, '_callback_high_level_requirementID'));
    $crud->callback_column('product_backlog_itemID', array($this, '_callback_product_backlog_itemID'));
    $crud->callback_column('sprint_backlogID', array($this, '_callback_sprint_backlogID'));
    if ($this->lan == "NL") {
      $crud->display_as('user_storyID', 'User story');
      $crud->display_as('high_level_requirementID', 'High level requirement');
      $crud->display_as('requirement', 'Requirement');
      $crud->display_as('product_backlog_itemID', 'Product backlog item');
      $crud->display_as('ready_for_sprint', 'Ready for sprint');
      $crud->display_as('sprint_backlogID', 'Sprint backlog');
      $crud->display_as('name', 'Name');
    } else if ($this->lan == "EN") {
      $crud->display_as('user_storyID', 'User story');
      $crud->display_as('high_level_requirementID', 'High level requirement');
      $crud->display_as('requirement', 'Requirement');
      $crud->display_as('product_backlog_itemID', 'Product backlog item');
      $crud->display_as('ready_for_sprint', 'Ready for sprint');
      $crud->display_as('sprint_backlogID', 'Sprint backlog');
      $crud->display_as('name', 'Name');
    } else if ($this->lan == "FR") {
      $crud->display_as('user_storyID', 'User story');
      $crud->display_as('high_level_requirementID', 'High level requirement');
      $crud->display_as('requirement', 'Requirement');
      $crud->display_as('product_backlog_itemID', 'Product backlog item');
      $crud->display_as('ready_for_sprint', 'Ready for sprint');
      $crud->display_as('sprint_backlogID', 'Sprint backlog');
      $crud->display_as('name', 'Name');
    } else if ($this->lan == "DE") {
      $crud->display_as('user_storyID', 'User story');
      $crud->display_as('high_level_requirementID', 'High level requirement');
      $crud->display_as('requirement', 'Requirement');
      $crud->display_as('product_backlog_itemID', 'Product backlog item');
      $crud->display_as('ready_for_sprint', 'Ready for sprint');
      $crud->display_as('sprint_backlogID', 'Sprint backlog');
      $crud->display_as('name', 'Name');
    }
    if ($this->lan == "NL") {
      ;
    } else if ($this->lan == "EN") {
      ;
    } else if ($this->lan == "FR") {
      ;
    } else if ($this->lan == "DE") {
      ;
    }
    if ($this->lan == "NL") {
      ;
    } else if ($this->lan == "EN") {
      ;
    } else if ($this->lan == "FR") {
      ;
    } else if ($this->lan == "DE") {
      ;
    }
    if ($this->lan == "NL") {
      ;
    } else if ($this->lan == "EN") {
      ;
    } else if ($this->lan == "FR") {
      ;
    } else if ($this->lan == "DE") {
      ;
    }
    $crud->set_relation('high_level_requirementID', 'high_level_requirement', '{version_nr}');
    $crud->set_relation('product_backlog_itemID', 'product_backlog_item', '{name}');
    $crud->set_relation('sprint_backlogID', 'sprint_backlog', '{name}');
    $field = $this->_get_table_subject(5);
    $crud->set_relation_n_n($field, 'user_story_business_role', 'business_role', 'user_storyID', 'business_roleID', '{name}');
    if ($this->lan == "NL") {
      ;
    } else if ($this->lan == "EN") {
      ;
    } else if ($this->lan == "FR") {
      ;
    } else if ($this->lan == "DE") {
      ;
    }
    $crud->field_type('ready_for_sprint', 'true_false');
    $crud->field_type('requirement', 'text');
    $crud->field_type('name', 'string');
    $crud->callback_read_field('high_level_requirementID', array($this, '_read_high_level_requirementID'));
    $crud->callback_read_field('product_backlog_itemID', array($this, '_read_product_backlog_itemID'));
    $crud->callback_read_field('sprint_backlogID', array($this, '_read_sprint_backlogID'));
    $output = $crud->render();
    $this->_scrumba_output($output);
  }

  function _add_high_level_requirement_hyperlink($value = null, $primary_key = null) {
    $table_subject = $this->_get_table_subject('high_level_requirement');
    $html = 'After adding a ' . $table_subject . ' use your browser back button to return to this page<br/>';
    $url = 'http://127.0.0.1/ezbuild30/ezbuild.php/high_level_requirement/index/add';
    $html = '<a href="' . $url . '">Click to add ' . $table_subject . '</a>';
    return $html;
  }

  function _add_product_backlog_item_hyperlink($value = null, $primary_key = null) {
    $table_subject = $this->_get_table_subject('product_backlog_item');
    $html = 'After adding a ' . $table_subject . ' use your browser back button to return to this page<br/>';
    $url = 'http://127.0.0.1/ezbuild30/ezbuild.php/product_backlog_item/index/add';
    $html = '<a href="' . $url . '">Click to add ' . $table_subject . '</a>';
    return $html;
  }

  function _add_sprint_backlog_hyperlink($value = null, $primary_key = null) {
    $table_subject = $this->_get_table_subject('sprint_backlog');
    $html = 'After adding a ' . $table_subject . ' use your browser back button to return to this page<br/>';
    $url = 'http://127.0.0.1/ezbuild30/ezbuild.php/sprint_backlog/index/add';
    $html = '<a href="' . $url . '">Click to add ' . $table_subject . '</a>';
    return $html;
  }

  public function _callback_high_level_requirementID($value, $row) {
    $field = 'high_level_requirementID';
    $keyfield = $row->$field;
    $sql = $this->_create_join_extra('user_story', 'high_level_requirement', $keyfield);
    if ((isset($sql) && ($sql != ""))) {
      $query = $this->scrumbadb->query($sql, array($keyfield));
      $hyperlinks = '';
      $hyper_text = '';
      foreach ($query->result() as $row) {
        foreach ($row as $key => $value) {
          $hyper_text .= $value . $this->delimiter;
        }
        $hyper_text = rtrim($hyper_text, $this->delimiter);
        $hyperlinks .= '<a href="' . site_url('index/read/' . $keyfield) . '">' . $hyper_text . '</a>';
      }
      if ($hyperlinks != '') {
        $hyperlinks = rtrim($hyperlinks, ', ');
        return $hyperlinks;
      }
    }
  }

  public function _callback_product_backlog_itemID($value, $row) {
    $field = 'product_backlog_itemID';
    $keyfield = $row->$field;
    $sql = $this->_create_join_extra('user_story', 'product_backlog_item', $keyfield);
    if ((isset($sql) && ($sql != ""))) {
      $query = $this->scrumbadb->query($sql, array($keyfield));
      $hyperlinks = '';
      $hyper_text = '';
      foreach ($query->result() as $row) {
        foreach ($row as $key => $value) {
          $hyper_text .= $value . $this->delimiter;
        }
        $hyper_text = rtrim($hyper_text, $this->delimiter);
        $hyperlinks .= '<a href="' . site_url('index/read/' . $keyfield) . '">' . $hyper_text . '</a>';
      }
      if ($hyperlinks != '') {
        $hyperlinks = rtrim($hyperlinks, ', ');
        return $hyperlinks;
      }
    }
  }

  public function _callback_sprint_backlogID($value, $row) {
    $field = 'sprint_backlogID';
    $keyfield = $row->$field;
    $sql = $this->_create_join_extra('user_story', 'sprint_backlog', $keyfield);
    if ((isset($sql) && ($sql != ""))) {
      $query = $this->scrumbadb->query($sql, array($keyfield));
      $hyperlinks = '';
      $hyper_text = '';
      foreach ($query->result() as $row) {
        foreach ($row as $key => $value) {
          $hyper_text .= $value . $this->delimiter;
        }
        $hyper_text = rtrim($hyper_text, $this->delimiter);
        $hyperlinks .= '<a href="' . site_url('index/read/' . $keyfield) . '">' . $hyper_text . '</a>';
      }
      if ($hyperlinks != '') {
        $hyperlinks = rtrim($hyperlinks, ', ');
        return $hyperlinks;
      }
    }
  }

  public function _read_high_level_requirementID($value, $primary_key) {
    $sql = $this->_create_join_extra('user_story', 'high_level_requirement', $primary_key);
    if ((isset($sql) && ($sql != ""))) {
      return ( $this->_create_hyperlinks($sql, $primary_key, 'high_level_requirement', Array('version_nr')));
    }
  }

  public function _read_product_backlog_itemID($value, $primary_key) {
    $sql = $this->_create_join_extra('user_story', 'product_backlog_item', $primary_key);
    if ((isset($sql) && ($sql != ""))) {
      return ( $this->_create_hyperlinks($sql, $primary_key, 'product_backlog_item', Array('name')));
    }
  }

  public function _read_sprint_backlogID($value, $primary_key) {
    $sql = $this->_create_join_extra('user_story', 'sprint_backlog', $primary_key);
    if ((isset($sql) && ($sql != ""))) {
      return ( $this->_create_hyperlinks($sql, $primary_key, 'sprint_backlog', Array('name')));
    }
  }

}
 


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 12 February 2015 - 05:57 AM

hey John. ... sorry if i missed out some place but that is 1 function i have altered in my core GC. Thought i had shared it... some other older posts... and never got bothrered on the same.... so didnt realize ppl would be missing the functionality..

//Code altered by Amit Shah
	protected function get_true_false_readonly_input($field_info,$value)
	{
		$value_is_null = empty($value) && $value !== '0' && $value !== 0 ? true : false;
		$true_string = is_array($field_info->extras) && array_key_exists(1,$field_info->extras) ? $field_info->extras[1] : $this->default_true_false_text[1];
		$false_string =  is_array($field_info->extras) && array_key_exists(0,$field_info->extras) ? $field_info->extras[0] : $this->default_true_false_text[0];
		
		return $value === '1' || ($value_is_null && $field_info->default === '1') ? $true_string : $false_string;
	}
	
	//Code altered by Amit Shah
	protected function get_upload_file_readonly_input($field_info,$value)
	{

		$this->load_js_fancybox();
		
		$this->set_js_config($this->default_javascript_path.'/jquery_plugins/config/jquery.fancybox.config.js');
		
		$unique = mt_rand();
		
		$uploader_display_none 	= empty($value) ? "" : "display:none;";
		$file_display_none  	= empty($value) ?  "display:none;" : "";
		
		$is_image = !empty($value) &&
		( substr($value,-4) == '.jpg'
				|| substr($value,-4) == '.png'
				|| substr($value,-5) == '.jpeg'
				|| substr($value,-4) == '.gif'
				|| substr($value,-5) == '.tiff')
				? true : false;
		
		$image_class = $is_image ? 'image-thumbnail' : '';
		
		$file_url = base_url().$field_info->extras->upload_path.'/'.$value;
		
		$input = "<div id='success_$unique' class='upload-success-url' style='$file_display_none padding-top:7px;'>";
		$input .= "<a href='".$file_url."' id='file_$unique' class='open-file";
		//Code altered by Amit Shah - for the sake of using thumbnails
		$_file_url = $field_info->extras->upload_path."/$value";
		//$input .= $is_image ? " $image_class'><img src='".$file_url."' height='50px'>" : "' target='_blank'>$value";
		$input .= $is_image ? " $image_class'>" . $this->img->rimg($_file_url, array('shortside'=>50, 'sharpen'=>true)) : "' target='_blank'>$value";
		//Code Alteration ends here
		$input .= "</a> ";
		$input .= "</div><div style='clear:both'></div>";
		
		return $input;
	}

Anyways,... here are the 2 functions altered .. add them and enjoy ...!!!

 

Happy GCing :)