public function _getJSON() { $data = array(); $data[] = array(); $id = key($this->dataout); $joins = dbfn::_getJoins($this->table); // Prepare the parameters for the query. $oQ = new formfilterpage($this->table, $joins); #Get filter and pagination data $data[0] = $oQ->_getJSON(); for ($ii = 0; $ii < count($this->dataout[$id]); $ii++) { $data[1][] = "<input type=\"checkbox\" name=\"cid[]\" id=\"cid_{$ii}\" value=\"{$this->dataout[$id][$ii]}\" />"; } foreach ($this->cols as $col_index => $col) { if ($this->params[$col]->visible && $this->params[$col]->qv_enabled) { // make sure column is visible and quickview enabled $temp = array(); foreach ($this->dataout[$col] as $cell_index => $cell_value) { $is_sub = false; // Determine if we are dealing with a substitute value if (empty($this->params[$col]->qv_sub_col)) { # no sub $cid = $this->dataout[$id][$cell_index]; # pid of current row $table_temp = $this->table; $cell_val_temp = strlen($cell_value) <= 100 ? $cell_value : substr($cell_value, 0, 100) . "..."; } else { # sub one or more cols $is_sub = true; $sub_col = $this->params[$col]->qv_sub_col; $cid = $cell_value; #pid of subbed col $table_temp = $this->params[$col]->qv_sub_col_table; $sub_col_temp = explode(",,", $sub_col); $cell_val_temp = array(); foreach ($sub_col_temp as $sub_col_col) { $cell_val_temp[] = $this->dataout[$sub_col_col][$cell_index]; } $cell_val_temp = implode(" - ", $cell_val_temp); } $temp[] = $col_index != 1 && $is_sub === false ? $cell_val_temp : "<a href=\"javascript:void(0)\" rel=\"{$table_temp}__{$cid}\" class=\"qv-a\" tt=\"View more details for: {$cell_val_temp}\">{$cell_val_temp}</a>"; } $data[] = $temp; } } return json_encode($data); }
global $option; $option = req::_('option', 'default'); global $view; $view = req::_('view', $option); $views = explode('|', req::_('view', $option)); $data = array(); // array containing select query db object $formdata = array(); // array containing filter/pagination form data objects /** ** ** ** ** ** ** ** ** ** * INITIALIZE VIEWS FOR EACH TAB */ foreach ($views as $v) { // Set some params $table = TABLEPREFIX . $v; $joins = dbfn::_getJoins($table); // Prepare the parameters for the query. $oQ = new formfilterpage($table, $joins); #Get filter and pagination data $select = $oQ->_getQuery(); #Get query $data[$v] = new db($select); #Perform query and load the results into the data array $oQ->_update($data[$v]); #Update the filter/pagination object $formdata[$v] = $oQ; #Load filter/pagination object into formdata array } /** ** ** ** ** ** ** ** ** ** * LOAD UP THE QUICKVIEW VIEW */
public static function _getJoins($table) { $query = "SELECT * FROM `information_schema`.`key_column_usage` WHERE `REFERENCED_COLUMN_NAME` <> '' AND `CONSTRAINT_SCHEMA` = 'aimsysdb' AND `TABLE_NAME` = '{$table}'"; $oDB = new db($query); $rows = $oDB->rows; if (empty($rows)) { return false; } $return = array(); $reftables = array(); foreach ($rows as $row) { $return[] = "INNER JOIN `{$row['REFERENCED_TABLE_NAME']}` ON `{$row['REFERENCED_TABLE_NAME']}`.`{$row['REFERENCED_COLUMN_NAME']}` = `{$row['TABLE_NAME']}`.`{$row['COLUMN_NAME']}`"; $reftables[] = $row['REFERENCED_TABLE_NAME']; } foreach ($reftables as $reftable) { $temp = trim(dbfn::_getJoins($reftable)); if (!empty($temp)) { $return = array_merge($return, explode("\n", $temp)); } } return implode("\n", array_unique($return)); }