public function _storeData() { #setup some variables $user_id = $_SESSION['use_id']; $this->_isUpd(); #get fields $this->fields = $this->is_update ? dbfn::_getupdatefields($this->table) : dbfn::_getinsertfields($this->table); #build query $query = $this->is_update ? dbfn::_buildupdate($this->fields, $this->table, $this->prikey) : dbfn::_buildinsert($this->fields, $this->table); #get changes to the data $this->_getDataChanges(); #execute query $oResult = new db($query); $this->rowid = $this->is_update ? $this->rowid : $oResult->insert_id; #format output $output = $oResult->ret; #determine if operation was a success and store in history if ($output['msg_class'] == "success") { aimsys::_history($query, $this->changes, $this->table, $this->rowid); $output['js'] = $this->is_update || req::_('popup') != 0 ? "" : "Tabs.activeTab.new2view('{$this->table}','{$this->rowid}');"; //additional javascript to run for new records $output['rowid'] = $this->rowid; } return $output; }
public static function _buildselect($table, $pkey) { $select = "SELECT * FROM `%s` WHERE `%s` = %s LIMIT 1"; $s[] = $select; $s[] = $table; $s[] = $pkey; $s[] = req::_($pkey); $select = call_user_func_array('sprintf', $s); return $select; }
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 __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})" : ''; }
* Ingenious Design - http://in.genio.us * Jeremy Bloomstrom | jeremy@in.genio.us * * Created: 3/27/2013 * Last Updated: 8/21/2014 * * Changelog: * 8/21/2014 - Added comment header */ /** ** ** ** ** ** ** ** ** ** * SETUP PARAMETERS */ $return = 0; $table = req::_('table_name'); $prikey = dbfn::_getprimary($table); $id = req::_($prikey); $userid = $_SESSION['use_id']; #id of currently logged in user /** ** ** ** ** ** ** ** ** ** * SEE IF RECORD IS ALREADY CHECKED IN */ $query = "SELECT `checked_out`,`checked_out_id`,`checked_out_time` FROM `{$table}` WHERE `{$prikey}` = {$id} LIMIT 1"; $oDB = new db($query); $checkedout = count($oDB->rows) ? $oDB->rows[0]['checked_out'] : 0; $checkedout_id = count($oDB->rows) ? $oDB->rows[0]['checked_out_id'] : 0; $checkedout_time = count($oDB->rows) ? $oDB->rows[0]['checked_out_time'] : 0; if ($checkedout === 0) { // record is already checked in $return = <<<HTML checkout_message('That record has been checked in already.','information'); \$('.main-content.active .part.active #lb-edit').show();
/********************************************************************************************************************************* || || || AIMSys - Aircraft Inventory & Maintenance System || || Jeremy Bloomstrom || || Ingenious Design || || jeremy@in.genio.us || || March 27, 2013 || || || |________________________________________________________________________________________________________________________________| || || || || || popup.php || || VIEW || || || *********************************************************************************************************************************/ // Do Some Logic stuff $table = req::_('table'); $rowid = req::_('rowid', 'new'); $editing = true; // Initialize table by getting params and populating with data. $oEditor = new editor($table, $rowid); $oEditor->_getData(); $editor_html = $oEditor->_html(); // Get View $oView = new view($view); // Display View Script and View HTML echo document::_addScript($oView->_script()); echo document::_addScript("ready.js"); include_once $oView->_html(); echo '<div class="clear"></div>'; //pre($data);
/********************************************************************************************************************************* || || || AIMSys - Aircraft Inventory & Maintenance System || || Jeremy Bloomstrom || || Ingenious Design || || jeremy@in.genio.us || || March 27, 2013 || || || |________________________________________________________________________________________________________________________________| || || || || || editor.php || || VIEW || || || *********************************************************************************************************************************/ // Do Some Logic stuff $table = req::_('table'); $rowid = req::_('rowid', 'new'); $editing = req::_('editing', false); $editing = $editing == "false" ? false : $editing; // Determine if new record or update $content_header = $rowid != 'new' ? 'View' : 'New'; // Initialize table by getting params and populating with data. $oEditor = new editor($table, $rowid); $oEditor->_getData(); $editor_html = $oEditor->_refresh_edit_html(); // Get View $oView = new view($view); // Display View Script and View HTML include_once $oView->_html(); echo document::_addScript($oView->_script());
//Prepare table object $oTable = new table($table, $data[$v]->rows); echo trim($oTable->_getJSON()); } else { // Iterate through each object in the data array foreach ($data as $view => $datum) { $table = TABLEPREFIX . $view; //Prepare table object $oTable = new table($table, $datum->rows); $body_html = $oTable->_quickview(); //Prepare form object $form_html = $formdata[$view]->_getFormHTML(); $footer_html = $formdata[$view]->_getFooterHTML(); // Prepare subtabs $subtab_name = "Manage " . ucwords(str_replace("_", " ", $view)); $subtab_class = req::_('subtab', "manage-{$content_header}") == "manage-{$view}" ? 'active' : ''; $subtabs_html .= <<<HTML <li id="manage-{$view}" class="{$subtab_class} ui-corner-top">{$subtab_name}</li> HTML; // Prepare content $content_html .= <<<HTML \t<div id="manage-{$view}" class="{$subtab_class} part"> \t\t<div class="data row controls">{$form_html}</div> \t\t{$body_html} \t\t<div class="data row footer">{$footer_html}</div> \t</div> HTML; } // Get View $oView = new view('qv'); // Display View Script and View HTML
public function _quickview() { if (!empty($this->dataout)) { $return = <<<HTML <div class="qv-table" id="qv_table_{$this->table}" name="{$this->friendlytable}"> \t<div class="qv-col"> \t<div class="qv-cell"> \t<input type="checkbox" name="sel_all_{$this->table}" id="chk_sel_all" title="Check/Uncheck All" tt="Check/Uncheck All Rows" /> </div> <div class="qv-cell search"></div> HTML; $id = key($this->dataout); for ($ii = 0; $ii < count($this->dataout[$id]); $ii++) { $return .= <<<HTML \t<div class="qv-cell"> \t<input type="checkbox" name="cid[]" id="cid_{$ii}" value="{$this->dataout[$id][$ii]}" /> </div> HTML; } $return .= "</div>"; $prev_order = req::_('prev_order'); 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 // Prepare the column header $class = req::_('order') == $col ? 'active' : ''; $dir_icon = $prev_order == $col && req::_('dir') == 'DESC' ? 'icon-desc' : 'icon-asc'; $input_qv_search_name = empty($this->params[$col]->qv_sub_col) ? $col : $this->params[$col]->qv_sub_col; $val = req::_($input_qv_search_name); $return .= <<<HTML \t\t\t\t<div class="qv-col"> \t\t\t\t\t<div class="qv-cell"> <a tt="Click to sort by {$this->params[$col]->qv_label} in ascending order. Click again to sort descending." class="easyui-linkbutton table_heading {$class}" iconcls="{$dir_icon}" href="#" rel="{$input_qv_search_name}"> {$this->params[$col]->qv_label} </a>\t<span class="icon"></span> </div> <div class="qv-cell search"> \t<input type="text" name="{$input_qv_search_name}" size="{$this->params[$col]->input_size}" value="{$val}" tt="Search records by {$this->params[$col]->qv_label}" class="input-qv-cell-search" /> </div> HTML; // Prepare the cell data 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); } $return .= $col_index != 1 && $is_sub === false ? "<div class=\"qv-cell\">{$cell_val_temp}</div>" : "<div class=\"qv-cell\"><a href=\"javascript:void(0)\" rel=\"{$table_temp}__{$cid}\" class=\"qv-a\" tt=\"View more details for: {$cell_val_temp}\">{$cell_val_temp}</a></div>"; } $return .= <<<HTML \t\t\t\t</div> HTML; } } $return .= <<<HTML <div class="qv-col"> \t<div class="qv-cell"> <a href="#" id="lb-go" class="easyui-linkbutton" iconcls="icon-search" tt="Perform search">Go</a> \t</div> <div class="qv-cell search"> <a href="#" id="lb-reset" class="easyui-linkbutton" iconcls="icon-reload" tt="Reset search results">Reset</a> </div> </div> HTML; $return .= <<<HTML \t\t\t\t</div> HTML; //print_r($this->dataout); return $return; } else { return false; } }
* Created: 11/27/2012 * Last Updated: 8/21/2014 * * Changelog: * 8/21/2014 - Added comment header */ session_start(); /** ** ** ** ** ** ** ** ** ** * INCLUDES */ include_once "system/includes.php"; /** ** ** ** ** ** ** ** ** ** * SET PARAMETERS AND DETERMINE ACTION */ $action = req::_("action"); $controller = req::_("controller", "main"); if ($action == "logout") { include_once "controllers/logout.php"; } /** ** ** ** ** ** ** ** ** ** * DETERMINE IF SESSION IS VALID */ $valid_session = session::_check_session(); /** ** ** ** ** ** ** ** ** ** * LOAD CONTROLLER */ if ($valid_session) { include_once "controllers/{$controller}.php"; } else { include_once "controllers/login.php"; }
public function __invoke($a) { return req::_($this->{$a}, false); }
* Jeremy Bloomstrom | jeremy@in.genio.us * * Created: 11/27/2012 * Last Updated: 8/21/2014 * * Changelog: * 8/21/2014 - Added comment header */ /** ** ** ** ** ** ** ** ** ** * SETUP PARAMETERS */ 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();
* Last Updated: 8/21/2014 * * Changelog: * 8/21/2014 - Added comment header */ /** ** ** ** ** ** ** ** ** ** * SETUP PARAMETERS */ global $view; $view = req::_('view', 'login'); /** ** ** ** ** ** ** ** ** ** * PROCESS LOGIN REQUEST */ if (req::_('frm_name') == 'frm_login') { $username = req::_('use_username'); $password = req::_('use_password'); $login_attempt = session::_login($username, $password); if ($login_attempt) { // If login is successful, redirect back to router. $message = "Login Successful!"; header("Location: index.php"); } } /** ** ** ** ** ** ** ** ** ** * SHOW LOGIN FORM VIEW */ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="icon" href="http://aimsys.home/favicon.ico" />
} else { echo "<pre>" . $s . "</pre>"; } } function preh($s) { echo pre(htmlentities($s)); } function consoleLog($s) { if (is_array($s) || is_object($s)) { $return = "console.log(\"{\\n\""; foreach ($s as $key => $value) { $return .= " + \"\t[" . addslashes($key) . "] => " . addslashes($s->{$key}) . " \\n \""; } $return .= "+\"}\" );"; } else { $return = "console.log(\"" . addslashes($s) . "\");"; } return $return; } // RESET USER PASSWORD if (req::_chk('reset') > 0) { $id = req::_('reset'); $_REQUEST['use_id'] = $id; $query = "UPDATE `aimusers` SET `use_password` = md5(concat(`use_firstname`,`use_lastname`)) WHERE `use_id` = {$id} LIMIT 1"; $oResult = new db($query); foreach ($oResult->ret as $key => $value) { ${$key} = $value; } }
* Last Updated: 8/21/2014 * * Changelog: * 8/21/2014 - Added comment header */ /** ** ** ** ** ** ** ** ** ** * SETUP PARAMETERS */ global $view; global $option; $option = req::_('option', 'default'); $view = req::_('view', $option); /** ** ** ** ** ** ** ** ** ** * PROCESS THE REQUEST */ switch ($option) { case 'update_options': $table = req::_('table'); $col = req::_('col'); $val = req::_('value'); $oParams = new colparams($table, $col); $params = $oParams->_getvalues(); $return = editor::_getOptions($params, $val); echo $return; break; } ?>
* Superuser view, where table parameters are set up * * Ingenious Design - http://in.genio.us * Jeremy Bloomstrom | jeremy@in.genio.us * * Created: 11/27/2012 * Last Updated: 8/21/2014 * * Changelog: * 8/21/2014 - Added comment header */ /** ** ** ** ** ** ** ** ** ** * SETUP PARAMETERS */ global $view; global $option; $option = req::_('option', 'login'); $view = req::_('view', $option); /** ** ** ** ** ** ** ** ** ** * SHOW THE SUPERUSER VIEW */ switch ($option) { default: include "views/su.php"; break; } ?>
$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(); break; } /** ** ** ** ** ** ** ** ** ** * OUTPUT THE RESULTS */ switch ($frm_name) { case 'frm_editor': case 'frm_tableparam': if ($option != 'popup') { header('content-type: application/x-javascript');
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"; }