public function __construct($table, $cid = 'new') { global $view; $this->option = $view; $this->table = $table; $this->cid = $cid; $this->cols = dbfn::_getfields("aimnotes"); $this->popup = req::_('popup'); $this->editing = req::_('editing'); $this->params = array(); foreach ($this->cols as $col) { $oTemp = new colparams($this->table, $col); $this->params[$col] = $oTemp->_getvalues(); } }
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); }
public function __construct($table) { $_SESSION['rows_per_page'] = req::_('rows_per_page', 10, '_SESSION'); $this->table = $table; $this->order = req::_('order', dbfn::_getprimary($table)); $this->order_dir = req::_('dir', 'ASC'); $this->page = req::_('page', '1'); $this->rows_per_page = $_SESSION['rows_per_page'] = req::_('rows_per_page', $_SESSION['rows_per_page']); $this->filter_field = req::_('filter_field'); $this->filter_group = req::_('filter_group', -1); $this->filter_group = is_array($this->filter_group) ? implode(',', $this->filter_group) : $this->filter_group; $this->first_record = req::_chk('page') ? (req::_('page') - 1) * $this->rows_per_page + 1 : 1; $this->last_record = $this->first_record + $this->rows_per_page - 1; $this->limit = $this->first_record - 1 . "," . $this->rows_per_page; $this->q = req::_('q') == 'Search Records...' ? '' : req::_('q'); $this->where = $this->q != '' ? dbfn::_buildwhere($table, $this->q) : 1; $this->where .= $this->filter_group != -1 ? " AND `{$this->filter_field}` IN ({$this->filter_group})" : ''; }
public static function _login($username, $password) { global $session_length; $select = "SELECT * FROM `aimusers` WHERE `use_username` = %s AND `use_password` = md5(%s) LIMIT 1"; $select = dbfn::_sanitize($select, $username, $password); $oResult = new db($select); $row = $oResult->_getRow(); if ($row) { foreach ($row as $key => $value) { if (strpos($key, "password") === false) { $_SESSION[$key] = $value; } } $_SESSION['rows_per_page'] = ROWS_PER_PAGE; session::_refresh_session(); return true; } else { $_SESSION['message'] = "That username and password combination is not recognized. Plese try again."; $_SESSION['msg_class'] = "error"; return false; // bad login attempt } }
$option = req::_('option', 'default'); $view = req::_('view', $option); $frm_name = req::_('frm_name'); /** ** ** ** ** ** ** ** ** ** * PROCESS FORM */ switch ($frm_name) { case 'frm_tableparam': $oParams = new colparams(req::_('_table'), req::_('_col')); $oParams->_set($_POST); $output = $oParams->_store(); break; case 'frm_editor': $table = req::_('table_name'); // table name $prikey = dbfn::_getprimary($table); // get primary key name of table $id = req::_($prikey); // get id of record $oEditor = new editor($table, $id); $oEditor->_getData(); $oEditor->_setData($_POST); $output = $oEditor->_storeData(); break; case 'frm_storetabs': $tabs = req::_('Tabs', ''); $oResult = aimsys::_storeTabs($tabs); $output = $oResult->ret; break; case 'frm_gettabs': $t = aimsys::_getTabs();
private function _constructElement($params, $val = NULL) { /* params: [editable] => [visible] => [qv_enabled] => [qv_default] => [qv_order] => [qv_colminwidth] => [qv_label] => [qv_sub_col] => [input_type] => password [input_required] => 1 [input_validtype] => min>6 [input_firstvalue] => [input_firstlabel] => [input_multiple] => [input_size] => [input_values] => [input_labels] => [input_label] => Password : [input_attrs] => [fieldset] => [_table] => aimusers [_col] => use_password */ $output = array(); // Determine if we need label,value pairs. if (!empty($params->input_labels) && !empty($params->input_values)) { //Determine source of data - local or db $pair_source = strpos($params->input_labels, '||') !== false ? "local" : "db"; if ($pair_source == "local") { $labels = explode("||", $params->input_labels); $values = explode("||", $params->input_values); } else { $a = dbfn::_get_options($params->input_labels, $params->input_values); $labels = $a['labels']; $values = $a['values']; } } $label_class = $params->input_required ? "class=\"editor-label required-label\"" : "class=\"editor-label\""; $input_class = $params->input_required ? "class=\"editor-element required-input\" validType=\"{$params->input_validtype}\"" : "class=\"editor-element\" "; $disabled = $this->rowid != 'new' && $this->editing != 1 ? 'disabled="disabled"' : ''; $edit_buttons_style = $this->rowid != 'new' && $this->editing != 1 ? 'style="display:none"' : ''; $readonly = $params->editable ? '' : 'readonly="readonly"'; switch ($params->input_type) { case 'text': $output[0] = <<<HTML <label {$label_class} for="{$params->_col}">{$params->input_label}</label> HTML; $output[1] = <<<HTML <input {$readonly} {$disabled} {$input_class} type="{$params->input_type}" name="{$params->_col}" id="{$params->_col}" value="{$val}" {$params->input_attrs} /> HTML; break; case 'password': $output[0] = <<<HTML <label {$label_class} for="{$params->_col}">{$params->input_label}</label> HTML; $output[1] = <<<HTML <input style="width:100px;" {$input_class} type="{$params->input_type}" name="{$params->_col}" id="{$params->_col}" value="{$val}" disabled="disabled" readonly="readonly" {$params->input_attrs} /> <button {$edit_buttons_style} class="edit-buttons" type="button" onclick="change_password('#{$params->_col}',this)">Change</button> HTML; break; case 'hidden': $output[0] = <<<HTML <label {$label_class} for="{$params->_col}">{$params->input_label}</label> HTML; $output[1] = <<<HTML <input {$readonly} {$input_class} type="{$params->input_type}" name="{$params->_col}" id="{$params->_col}" value="{$val}" {$params->input_attrs} /> HTML; break; case 'textarea': $output[0] = <<<HTML <label {$label_class} for="{$params->_col}">{$params->input_label}</label> HTML; $output[1] = <<<HTML <textarea style="width:500px;" {$disabled} {$readonly} name="{$params->_col}" id="{$params->_col}" rows="{$params->input_size}" {$input_class} {$params->input_attrs} >{$val}</textarea> HTML; break; case 'checkbox': $checked = $val ? "checked=\"checked\"" : ''; $output[0] = <<<HTML <label {$label_class} for="{$params->_col}">{$params->input_label}</label> HTML; $output[1] = <<<HTML <input {$readonly} {$disabled} {$checked} {$input_class} type="{$params->input_type}" name="{$params->_col}" id="{$params->_col}" value="{$params->input_values}" {$params->input_attrs} /> HTML; break; case 'radio': $output[0] = ''; $output[1] = ''; foreach ($labels as $key => $option) { $checked = $val == $values[$key] ? "checked=\"checked\"" : ''; $output[0] .= <<<HTML \t\t\t\t\t\t<label {$label_class} for="{$params->_col}-{$key}">{$option}</label> HTML; $output[1] .= <<<HTML <input {$readonly} {$disabled} {$input_class} type="{$params->input_type}" name="{$params->_col}" id="{$params->_col}-{$key}" value="{$values[$key]}" {$params->input_attrs} /> <br /> HTML; } break; case 'select': $selected = empty($val) ? "selected=\"selected\"" : ''; $multiple = empty($params->input_multiple) ? '' : 'multiple="multiple"'; $output[0] = <<<HTML \t<label {$label_class} for="{$params->_col}">{$params->input_label}</label> HTML; $output[1] = <<<HTML \t\t\t<select {$readonly} {$disabled} {$input_class} {$multiple} name="{$params->_col}" id="{$params->_col}" {$params->input_attrs} > <option {$selected} value="{$params->input_firstvalue}">{$params->input_firstlabel}</option> HTML; if (!empty($params->qv_sub_col_table)) { $output[1] .= <<<HTML \t\t\t\t\t<option value="addnew" id="{$params->qv_sub_col_table}||{$params->qv_sub_col}">--Add New--</option> HTML; } foreach ($labels as $key => $option) { $selected = $val === $values[$key] ? "selected=\"selected\"" : ''; $output[1] .= <<<HTML \t\t\t\t\t\t<option {$selected} value="{$values[$key]}">{$option}</option> HTML; } $output[1] .= "</select> "; if (!empty($params->qv_sub_col_table)) { $output[1] .= <<<HTML \t<!--<button onclick="view_record('{$params->qv_sub_col_table}','#{$params->_col}')" type="button">→</button>--> <a href="#" onclick="view_record('{$params->qv_sub_col_table}','#{$params->_col}')" class="easyui-linkbutton" iconcls="icon-next" tt="View Record"></a> HTML; } break; default: $output = ''; break; } return $output; }
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 function __construct($table, $tables) { $this->table = $table; $this->tables = $tables; $this->ar_cols = dbfn::_getfields($table); $oPlist = new paramdefaults(); $aPlist = array(); foreach ($oPlist as $key => $value) { $aPlist[] = $value['label']; } $this->ar_params = $aPlist; $this->params = array(); foreach ($this->ar_cols as $col) { $this->params[$col] = new colparams($this->table, $col); } }
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)); }
function __construct($table, $joins = false) { global $option; global $view; $this->table = $table; $this->friendlytable = ucfirst(str_replace(TABLEPREFIX, '', $table)); $this->option = $option; $this->view = $view; $this->frm_name = "{$table}_filter_form"; $this->joins = $joins; // Are we actively performing a filter $this->apply = req::_('frm_name') == $this->frm_name ? true : false; if ($this->apply) { // actively applying this filter to the current table // Filter Params $filter = req::_('filter', -1); $this->filter = is_array($filter) ? implode(',', $filter) : $filter; // Build Pagination params $_SESSION['rows_per_page'] = req::_('rows_per_page', ROWS_PER_PAGE, '_SESSION'); $rows_per_page = $_SESSION['rows_per_page'] = req::_('rows_per_page', $_SESSION['rows_per_page']); $first_record = req::_chk('page') ? (req::_('page') - 1) * $rows_per_page + 1 : 1; $last_record = $first_record + $rows_per_page - 1; // Build where statement $search_criteria = req::_('search_criteria', ''); if (!empty($search_criteria)) { $search_criteria = urldecode($search_criteria); $pairs = explode('&', $search_criteria); $this->search_criteria = array(); foreach ($pairs as $pair) { $p = explode('=', $pair); $this->search_criteria[$p[0]] = $p[1]; } } $this->where = !empty($this->search_criteria) ? dbfn::_buildwhere2($this->search_criteria) : 1; // Build order criteria $this->order = req::_('order', dbfn::_getPrimary($table)); $this->dir = req::_('dir', 'ASC'); } else { // not actively applying any filters to this table $this->filter = -1; $rows_per_page = $_SESSION['rows_per_page']; $first_record = 1; $last_record = $first_record + $rows_per_page - 1; $this->where = 1; $this->order = dbfn::_getPrimary($table); $this->dir = 'ASC'; } $this->limit = $first_record - 1 . "," . $rows_per_page; $this->page = req::_('page', 1); $this->rows_per_page = $rows_per_page; // Find total records $select2 = "SELECT count(*) AS `c` FROM `{$table}` {$joins} WHERE {$this->where}"; $oTemp = new db($select2); $this->total_rows = $oTemp->_getResult(); $this->first_record = $this->rows_per_page < $this->total_rows ? $first_record : 1; $this->last_record = $this->total_rows <= $last_record ? $this->total_rows : $last_record; $this->total_pages = ceil($this->total_rows / $this->rows_per_page); // Update limit and page number if necessary $this->limit = $this->first_record - 1 . "," . $rows_per_page; $this->page = $this->rows_per_page < $this->total_rows ? $this->page : 1; // Row message: Displaying x - y of z records... $this->row_message = $this->total_rows > 0 ? "Showing " . $this->first_record . " - " . $this->last_record . " of " . $this->total_rows . " rows." : "<font style='color:red'>No records found.</font>"; $this->row_message_class = $this->total_rows > 0 ? "ui-state-success" : "ui-state-error"; }