Example #1
0
 function mainLayout($container)
 {
     # Erase default help message
     vgfSet('htmlHelp', '');
     $top = $container;
     # Pull the values
     $row = SQL_OneRow("Select * from " . $this->table_id);
     # Basic information at top
     html('div', $top, 'Instance Configuration', 'hero-unit');
     html('p', $top, 'Any changes made here will take immediate 
         effect for all users of this program, except where a user
         has configured their own preferred setting.');
     # Set up titles
     $table = html('table', $top);
     $table->addClass('table table-bordered table-condensed table-hover table-striped');
     $table->hp['id'] = 'x2data1';
     $thead = html('thead', $table);
     $tr = html('tr', $thead);
     $tr->h('th', 'Setting', 'dark');
     $tr->h('th', 'Default Value', 'dark');
     $tr->h('th', ' ', 'dark');
     $tr->h('th', 'Instance Value', 'dark');
     # Now put out inputs for each one
     $tbody = html('tbody', $table);
     $askip = array('recnum', '_agg', 'skey_quiet', 'skey');
     foreach ($this->flat as $column_id => $colinfo) {
         if (in_array($column_id, $askip)) {
             continue;
         }
         $tr = html('tr', $tbody);
         $tr->hp['id'] = 'tr_' . $column_id;
         $tr->SetAsParent();
         $td = html('td', $tr, $colinfo['description']);
         # The default value
         $td = html('td', $tr, ConfigGet($column_id, '*null*', array('user', 'inst')));
         $td->hp['id'] = 'def_' . $column_id;
         # The reset
         $td = html('td', $tr);
         $button = html('a-void', $td, 'Use Default');
         $button->hp['onclick'] = "makeDefault('{$column_id}')";
         # the input
         $input = input($colinfo);
         $input->hp['id'] = 'inp_' . $column_id;
         if ($colinfo['type_id'] == 'text') {
             $input->setHTML($row[$column_id]);
         } else {
             $input->hp['value'] = $row[$column_id];
             x4Script('$a.byId("' . $input->hp['id'] . '").value="' . $row[$column_id] . '"');
         }
         $input->hp['onchange'] = 'instaSave(this)';
         $input->ap['skey'] = $row['skey'];
         $td = html('td', $tr);
         $td->addChild($input);
     }
 }
 function mainLayout($container)
 {
     # Erase default help message
     vgfSet('htmlHelp', '');
     html('h1', $container, 'Configuration Review');
     $table = html('table', $container);
     $table->hp['id'] = 'x2data1';
     $thead = html('thead', $table);
     $tr = html('tr', $thead);
     $tr->h('th', 'Setting', 'dark');
     $tr->h('th', 'Framework', 'dark');
     $tr->h('th', 'Application', 'dark');
     $tr->h('th', 'Instance', 'dark');
     $tr->h('th', 'User', 'dark');
     $tr->h('th', 'Your Setting', 'dark');
     # Include any of the files that exist
     $dir = fsDirTop() . "/dynamic/table_config";
     $configfw = $configapp = $configinst = $configuser = array();
     if (file_exists($dir . 'fw.php')) {
         include $dir . 'fw.php';
     }
     if (file_exists($dir . 'app.php')) {
         include $dir . 'app.php';
     }
     if (file_exists($dir . 'inst.php')) {
         include $dir . 'inst.php';
     }
     if (file_exists($dir . 'user_' . SessionGet('UID') . '.php')) {
         include $dir . 'user_' . SessionGet('UID') . '.php';
     }
     $dd = ddTable('configapp');
     $askip = array('recnum', 'skey', 'skey_quiet', '_agg', 'uid_ins');
     $tbody = html('tbody', $table);
     $flipper = 0;
     foreach ($dd['flat'] as $column_id => $colinfo) {
         if (in_array($column_id, $askip)) {
             continue;
         }
         $tr = html('tr', $tbody);
         if ($flipper > 2) {
             $tr->addClass('lightgray');
         } else {
             if ($flipper != 2) {
                 $tr->addClass('lightgraybottom');
             }
         }
         $flipper += 1;
         if ($flipper == 6) {
             $flipper = 0;
         }
         html('td', $tr, $colinfo['description']);
         # The four levels from files
         html('td', $tr, a($configfw, $column_id));
         html('td', $tr, a($configapp, $column_id));
         html('td', $tr, a($configinst, $column_id));
         if (a($colinfo, 'flagcarry', 'N') == 'Y') {
             html('td', $tr, a($configuser, $column_id));
         } else {
             html('td', $tr, 'n/a');
         }
         # The final resolved value
         html('td', $tr, ConfigGet($column_id));
     }
 }
Example #3
0
 function mainLayout($container)
 {
     # Erase default help message
     vgfSet('htmlHelp', '');
     $top = $container;
     # Pull the values
     # For a user, if there is no row, enter one and try again
     $dd = ddTable("configuser");
     $view = ddView('configuser');
     $row = SQL_AllRows("Select * from {$view}");
     if (count($row) == 1) {
         $row = $row[0];
     } else {
         SQL("Insert into {$view} (skey_quiet) values ('N')");
         $row = SQL_OneRow("Select * from {$view}");
     }
     # Basic information at top
     html('h1', $top, 'User Configuration');
     html('p', $top, 'Any changes made here will take immediate 
         effect.');
     # Set up titles
     $table = html('table', $top);
     $thead = html('thead', $table);
     $tr = html('tr', $thead);
     $tr->h('th', 'Setting', 'dark');
     $tr->h('th', 'Your Value', 'dark');
     $tr->h('th', 'Default Value', 'dark');
     $tr->h('th', '&nbsp', 'dark');
     # Now put out inputs for each one
     $tbody = html('tbody', $table);
     $askip = array('recnum', '_agg', 'skey_quiet', 'skey', 'uid_ins');
     foreach ($this->flat as $column_id => $colinfo) {
         if (in_array($column_id, $askip)) {
             continue;
         }
         $tr = html('tr', $tbody);
         $tr->hp['id'] = 'tr_' . $column_id;
         $tr->SetAsParent();
         $td = html('td', $tr, $colinfo['description']);
         # the input
         $input = input($colinfo);
         $input->hp['id'] = 'inp_' . $column_id;
         if ($colinfo['type_id'] == 'text') {
             $input->setHTML($row[$column_id]);
         } else {
             $input->hp['value'] = $row[$column_id];
             x4Script('$a.byId("' . $input->hp['id'] . '").value="' . $row[$column_id] . '"');
         }
         $input->hp['onchange'] = 'instaSave(this)';
         $input->ap['skey'] = $row['skey'];
         $td = html('td', $tr);
         $td->addChild($input);
         # The default value
         $td = html('td', $tr, ConfigGet($column_id, '*null*', array('user')));
         $td->hp['id'] = 'def_' . $column_id;
         # The reset
         $td = html('td', $tr);
         $button = html('a-void', $td, 'Use Default');
         $button->hp['onclick'] = "makeDefault('{$column_id}')";
     }
 }
Example #4
0
/**
name:rowsForSelect
parm:string Table_id
parm:string First_Letters
return:array rows

Returns an array of rows that can be put into a drop-down select box.
The first column is always "_value" and the second is always "_display".

The second parameter, if provided, filters to the results so that
only values of _display that start with "First_Letters" are returned.

For a multiple-column primary key, this routine will filter for any pk
column that exists in the session array "ajaxvars".  This feature is
controlled by an (as-yet undocumented) feature in [[ahInputsComprehensive]]
that can make inputs use Ajax when their value changes to store their
value in the session on the server.

This was created 1/15/07 to work with Ajax-dynamic-list from
dhtmlgoodies.com.
*/
function RowsForSelect($table_id, $firstletters = '', $matches = array(), $distinct = '', $allcols = false)
{
    $table = DD_TableRef($table_id);
    // Determine which columns to pull and get them
    // KFD 10/8/07, a DISTINCT means we are pulling a single column of
    //              a multiple column key, pull only that column
    if ($distinct != '') {
        $proj = $distinct;
    } else {
        if (ArraySafe($table['projections'], 'dropdown') == '') {
            if (!vgfGet('x6')) {
                $proj = $table['pks'];
            } else {
                $proj = $table['projections']['_uisearch'];
            }
        } else {
            $proj = $table['projections']['dropdown'];
        }
    }
    $aproj = explode(',', $proj);
    $acollist = array();
    foreach ($aproj as $aproj1) {
        $acollist[] = "COALESCE({$aproj1},'')";
    }
    $collist = str_replace(',', " || ' - ' || ", $proj);
    //$collist = implode(" || ' - ' || ",$acollist);
    //syslog($collist);
    // Get the primary key, and resolve which view we have perms for
    // KFD 10/8/07, do only one column if passed
    if ($distinct != '') {
        $pk = $distinct;
    } else {
        $pk = $table['pks'];
    }
    $view_id = ddtable_idResolve($table_id);
    // Initialize the filters
    $aWhere = array();
    // Generate a filter for each pk that exists in session ajaxvars.
    // There is a BIG unchecked for issue here, which is that a multi-column
    //  PK must have *all but one* column supplied, and it then returns
    //  the unsupplied column.
    $pkeys = explode(',', $table['pks']);
    $ajaxvars = afromGP('adl_');
    foreach ($pkeys as $index => $pkey) {
        if (isset($ajaxvars[$pkey])) {
            $aWhere[] = "{$pkey}=" . SQLFC($ajaxvars[$pkey]);
            // This is important!  Unset the pk column, we'll pick the leftover
            unset($pkeys[$index]);
        }
    }
    // If we did the multi-pk route, provide the missing column
    //  as the key value
    if (count($ajaxvars) > 0) {
        $pk = implode(',', $pkeys);
    }
    // Determine if this is a filtered table
    if (isset($table['flat']['flag_noselect'])) {
        $aWhere[] = "COALESCE(flag_noselect,'N')<>'Y'";
    }
    // Add more matches on
    foreach ($matches as $matchcol => $matchval) {
        $aWhere[] = $matchcol . ' = ' . SQLFC($matchval);
    }
    // See if there is a hardcoded filter in the program class
    $obj = dispatchObject($table_id);
    if (method_exists($obj, 'aSelect_where')) {
        $aWhere[] = $obj->aSelect_where();
        if (ConfigGet('LOG_SQL', 'Y') == 'Y') {
            sysLog(LOG_NOTICE, $obj->aSelect_Where());
        }
    }
    // If "firstletters" have been passed, we will filter each
    // select column on it
    //
    // KFD 8/8/07, a comma in first letters now means look in
    //             1st column only + second column only
    $SLimit = '';
    $xWhere = array();
    if ($firstletters == '*') {
        // do nothing, no where clauses
    } elseif ($firstletters != '') {
        $SLimit = "Limit 40 ";
        if (strpos($firstletters, ',') === false) {
            // original code, search all columns
            $implode = ' OR ';
            foreach ($aproj as $aproj1) {
                $type_id = $table['flat'][$aproj1]['type_id'];
                $subs = '';
                if (!in_array($type_id, array('char', 'vchar', 'text'))) {
                    $subs = '::varchar';
                }
                $sl = strlen($firstletters);
                $xWhere[] = "SUBSTRING(LOWER({$aproj1}{$subs}) FROM 1 FOR {$sl})" . "=" . strtolower(SQLFC($firstletters));
            }
        } else {
            // New code 8/8/07, search first column, 2nd, third only,
            // based on existence of commas
            $implode = ' AND ';
            $afl = explode(',', $firstletters);
            foreach ($afl as $x => $fl) {
                $type_id = $table['flat'][$aproj1]['type_id'];
                $subs = '';
                if (!in_array($type_id, array('char', 'vchar', 'text'))) {
                    $subs = '::varchar';
                }
                $sl = strlen($fl);
                $xWhere[] = "SUBSTRING(LOWER({$aproj[$x + 1]}{$subs}) FROM 1 FOR {$sl})" . "=" . strtolower(SQLFC($fl));
            }
        }
    }
    if (count($xWhere) > 0) {
        $aWhere[] = "(" . implode($implode, $xWhere) . ")";
    }
    // Finish off the where clause
    if (count($aWhere) > 0) {
        $SWhere = "WHERE " . implode(' AND ', $aWhere);
    } else {
        $SWhere = '';
    }
    // Execute and return
    $sDistinct = $distinct != '' ? ' DISTINCT ' : '';
    $SOB = $aproj[0];
    if ($allcols) {
        # KFD 6/9/08, added in automatic ordering on queuopos column
        $OB = isset($table['flat']['queuepos']) ? 'queuepos' : '2';
        $sq = "SELECT skey,{$proj}\n              FROM {$view_id}\n           {$SWhere}\n            ORDER BY {$OB} {$SLimit}";
    } else {
        $sq = "SELECT {$sDistinct} {$pk} as _value,{$collist} as _display\n              FROM {$view_id}\n           {$SWhere}\n             ORDER BY {$SOB} {$SLimit} ";
    }
    /*
    openlog(false,LOG_NDELAY,LOG_USER);
    if ( ConfigGet( 'flag_syslog', 'Y' ) == 'Y' ) {
    	   syslog(LOG_INFO,$table['projections']['dropdown']);
    	   syslogbodyRows
    	   (LOG_INFO,$sq);
    }
    closelog();
    */
    if (ConfigGet('flag_syslog', 'Y') == 'Y') {
        syslog(LOG_INFO, $sq);
    }
    $rows = SQL_Allrows($sq);
    return $rows;
}