Example #1
0
 /**
  *  Generate a comparison expression using dashes, commas etc.
  *
  *  @param string $table_id the table
  *  @param string $colname  the column
  *  @param string $colinfo  other column information
  *  @access private
  */
 function SQLCompareStar($table, $colname, $colinfo)
 {
     // Get the uifilter being used and its value
     // skip the asterisk and the @sign
     $uif_name = substr($colinfo['compare'], 2);
     #x4Debug($this->yamlP2['uifilter']);
     $uiv_val = a($this->yamlP2['uifilter'][$uif_name], 'value');
     if ($uiv_val == '') {
         return '';
     }
     // Get data dictionary
     $dd = ddTable($table);
     # KFD 6/18/08, route out to the new universal sqlFilter()
     $rv = sqlFilter($dd['flat'][$colname], $uiv_val, $dd['table_id']);
     #x4Debug($colname);
     #x4Debug($uiv_val);
     #x4Debug($rv);
     if ($rv != '') {
         return "(" . $rv . ")";
     }
     return '';
     #return "(".rff_OneCol($dd['flat'][$colname],$colname,$uiv_val).")";
 }
 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
    /**
     * The user is running on a server and wants to get the
     * latest versions available.  Show them the list of
     * applications
     *
     */
    function mainHTML()
    {
        $rows = svnVersions();
        ?>
        <style>
        #chart {
            border-spacing: 0;
            border-collapse: collapse;
        }
        #chart th {
            padding: 2px;
            border: 1px solid #C0C0C0;
            background-color: #E0E0E0;
        }
        #chart td {
            padding: 2px;
            border: 1px solid #C0C0C0;
        }
        </style>
        <script>
        function svnSearch() {
            var url='?gp_page=a_pullsvn&svnpull=1&gp_out=process';
            Popup(url,'Pull Software Updates');
        }
        </script>
        
        
        
        <div id="svn1">
        <h1>Pull Code From Subversion</h1>
        
        <?php 
        if (count($rows) == 0) {
            ?>
            <b>None of your applications have the "Overwrite From SVN" flag
               set to "Y".  Therefore there is nothing to do on this page.
               <br/><br/>
               This may not be a bad thing -- normally on a development
               workstation you do not use this feature because you use a 
               Subversion client manually.
               <br/><br/>
               If this is a server
               then you will want to set the "Overwrite From SVN" flag to 
               "Y" for each application you will host on this server.
            </b>
            <?php 
            return;
            ?>
        <?php 
        }
        ?>
        
        <div class="alert alert-warning">
        Warning! If you use this program on a development workstation you
        can <i>overwrite your own work</i>, because this program 
        unconditionally overwrites the application code.  On development
        workstations you should use manual Subversion tools.
        </div>
        <h3>Application List</h3>
        <table class="table table-bordered table-condensed table-striped table-hover">
          <thead><tr><th>Application</th>
                     <th>Local Version</th>
                     <th>User Name</th>
                     <th>Password</th>
                     <th>Respository</th>
            </tr>
          </thead>
            <tbody>
        <?php 
        $dd = ddTable('applications');
        foreach ($rows as $row) {
            $tr = html('tr');
            $a = html('a');
            $a->setHTML($row['application']);
            $a->hp['href'] = "?gp_page=applications&gp_skey=" . $row['skey'];
            $td = html('td', $tr, $a->bufferedRender());
            $td = html('td', $tr, $row['local']);
            $td = html('td', $tr, $row['svn_uid']);
            $pwd = $row['svn_pwd'] == '' ? '' : '********';
            $td = html('td', $tr, $pwd);
            $td = html('td', $tr, $row['svn_url']);
            //$td->hp['colspan'] = 4;
            $tr->render();
        }
        ?>
            </tbody>
        </table>

        <br/>
        <br/>
        This program will use any username and password that are supplied.
        If they are not supplied, the program assumes they are not
        needed.  If you need to change the username or password, go to the
        details page for the particular application.
        <br/>
        <br/>
        <a href="javascript:svnSearch()">Search For Updates Now</a>

        <br/>
        <br/>
        <a href="javascript:window.location.reload()">Refresh This Page</a>
        
        </div>
        <?php 
    }
Example #4
0
 /**
  * Generate search results for an x4browse/search
  *
  * @author: Kenneth Downs
  */
 function browseFetch()
 {
     #  This is the list of columns to return
     $acols = explode(',', $this->dd['projections']['_uisearch']);
     #  By default the search criteria come from the
     #  variables, unless it is a child table search
     $vals = aFromGP('x4w_');
     $awhere = array();
     $tabPar = gp('tableIdPar');
     if ($tabPar != '') {
         $ddpar = ddTable(gp('tableIdPar'));
         $pks = $ddpar['pks'];
         $stab = ddView(gp('tableIdPar'));
         $skey = SQLFN(gp('skeyPar'));
         $vals2 = SQL_OneRow("SELECT {$pks} FROM {$stab} WHERE skey = {$skey}");
         if (!$vals2) {
             $vals2 = array();
         }
         $vals = array_merge($vals, $vals2);
     }
     # Build the where clause
     #
     foreach ($vals as $column_id => $colvalue) {
         if (!isset($this->flat[$column_id])) {
             continue;
         }
         $colinfo = $this->flat[$column_id];
         $exact = isset($vals2[$column_id]);
         //$tcv  = trim($colvalue);
         $tcv = $colvalue;
         $type = $colinfo['type_id'];
         if ($tcv != "") {
             // trap for a % sign in non-string
             $xwhere = sqlFilter($this->flat[$column_id], $tcv);
             if ($xwhere != '') {
                 $awhere[] = "({$xwhere})";
             }
         }
     }
     # <----- RETURN
     if (count($awhere) == 0) {
         x4Debug("returning");
         return;
     }
     # Generate the limit
     # KFD 11/12/08, modified to respect sql_limit, with default of 100
     $SLimit = ' LIMIT ' . configGet('sql_limit', 100);
     if ($tabPar != '') {
         if (a($this->dd['fk_parents'][$tabPar], 'uiallrows', 'N') == 'Y') {
             $SLimit = '';
         }
     }
     #  Build the Order by
     #
     $ascDesc = gp('sortAD') == 'ASC' ? ' ASC' : ' DESC';
     $aorder = array();
     $searchsort = trim(a($this->dd, 'uisearchsort', ''));
     if (gpExists('sortAD')) {
         $aorder[] = gp('sortCol') . ' ' . gp('sortAD');
     }
     if ($searchsort != '') {
         $aocols = explode(",", $searchsort);
         foreach ($aocols as $pmcol) {
             $char1 = substr($pmcol, 0, 1);
             $column_id = substr($pmcol, 1);
             if ($char1 == '+') {
                 $aorder[] = $column_id . ' ASC';
             } else {
                 $aorder[] = $column_id . ' DESC';
             }
         }
         $SQLOrder = " ORDER BY " . implode(',', $aorder);
     } else {
         # KFD 6/18/08, new routine that works out sort
         $aorder = sqlOrderBy($vals);
         if (count($aorder) == 0) {
             $SQLOrder = '';
         } else {
             $SQLOrder = " ORDER BY " . implode(',', $aorder);
         }
     }
     # just before building the query, drop out
     # any columns that have a table_id_fko to the parent
     foreach ($acols as $idx => $column_id) {
         if ($this->flat[$column_id]['table_id_fko'] == $tabPar && $tabPar != '') {
             unset($acols[$idx]);
         }
     }
     // Build the where and limit
     $SWhere = ' WHERE ' . implode(' AND ', $awhere);
     // Retrieve data
     $SQL = "SELECT skey," . implode(',', $acols) . "  FROM " . $this->view_id . $SWhere . $SQLOrder . $SLimit;
     $answer = SQL_AllRows($SQL);
     $this->browseFetchModify($answer);
     x4Data('browseFetch', $answer);
     return;
 }
Example #5
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 #6
0
 function androHTMLxrefs($table_id, $height = 300)
 {
     # Extreme basics for child tables.
     $this->htype = 'div';
     $this->hp['x6table'] = $table_id;
     $this->hp['xCount'] = 0;
     # First bit of business is to run through and find
     # out if we actually have any kids.
     $dd = ddTable($table_id);
     $kids = array();
     $atts = array();
     foreach ($dd['fk_children'] as $table_kid => $info) {
         if (arr($info, 'x6xref', '') != '') {
             $kids[$table_kid] = $info['x6xref'];
             $atts[] = "{$table_kid}:{$info['x6xref']}";
         }
     }
     # If no kids, set ourselves to be invisible
     if (count($kids) == 0) {
         $this->hp['style'] = 'display: none;';
         return;
     }
     $this->hp['xCount'] = count($kids);
     $options = array('x6profile' => 'x6xrefs', 'x6table' => $table_id, 'styles' => array('overflow-y' => 'scroll'));
     $tabs = $this->addTabs($table_id . '_xrefs', $height, $options);
     $tabs->ul->hp['kids'] = implode("|", $atts);
     # If we are still here, we have at least one kid.  Let's
     # put in a tab bar and start adding the kids.
     foreach ($kids as $kid => $x) {
         $pane = $tabs->addTab($dd['fk_children'][$kid]['description']);
     }
 }
Example #7
0
function searchBrowse($table, $whr)
{
    // Grab the parameters of interest to us
    $sortCol = gp('sortCol');
    $sortDir = gp('sortDir');
    $columns = gp('columns');
    $offset = gp('offset', 0);
    $tabdd = ddTable($table);
    $flat =& $tabdd['flat'];
    // Loop through and build "like" clauses
    $sflike = array();
    foreach ($flat as $colname => $colinfo) {
        if (isset($whr[$colname])) {
            $tcv = trim($whr[$colname]);
            $type = $colinfo['type_id'];
            if ($type == 'dtime' || $type == 'date') {
                $tcv = tsFromAny($tcv);
            }
            if ($tcv != "") {
                // trap for a % sign in non-string
                $sflike[] = '(' . searchBrowseOneCol($type, $colname, $tcv) . ')';
            }
        }
    }
    // KFD 12/1/07, removed this, prevent returnAll feature from working
    // If there are no where clauses, forget it, return w/o doing anything
    //if(count($sflike)==0) return;
    $sWhere = count($sflike) == 0 ? '' : ' WHERE ' . implode(' AND ', $sflike);
    $view = ddViewFromTab($table);
    $sq = "SELECT *\n          FROM {$view}\n         {$sWhere}\n         ORDER BY {$sortCol} {$sortDir} LIMIT 1000";
    $results = x4SQLAllRows($sq);
    ReturnItem('data', $table, $results);
}
Example #8
0
 function fetchParent()
 {
     $ddpar = ddTable(gp('tableIdPar'));
     $pks = $ddpar['pks'];
     $stab = ddView(gp('tableIdPar'));
     $skey = SQLFN(gp('skeyPar'));
     $vals2 = SQL_OneRow("SELECT {$pks} FROM {$stab} WHERE skey = {$skey}");
     if (!$vals2) {
         $vals2 = array();
     }
     return $vals2;
 }
 /**
  *  Automated report setup.  Establishes all hardcoded
  *  defaults, all overrides from YAML file, captions, column
  *  sizes, page orientation, and so forth and so on.
  *
  *  This class can output to PDF or onscreen (and later to
  *  csv), but by far the most complex option is the 
  *  PDF version.  We do not wrap the PDF stuff in conditionals
  *  except where necessary, so as to prevent loading up the
  *  class with lots of unnecessary conditionals.  This means
  *  a few properties get set that end up being ignored, but
  *  that is no big deal.
  *
  *  @param string $yamlP2  The processed page definition     
  *  @since 12/16/07
  */
 function mainSetup($yamlP2)
 {
     // Default UOM is points, so these are 1/2 inch margins
     $this->margin_left = 36;
     $this->margin_top = 36;
     $this->SetMargins($this->margin_left, $this->margin_top);
     // Set defaults.  Font name and size can be pulled
     // from the YAML definition, the rest are hardcoded
     // or derived.
     $this->fontname = a($yamlP2['options'], 'fontname', 'Arial');
     $this->fontsize = a($yamlP2['options'], 'fontsize', 12);
     $this->linespacing = 1;
     $this->cpi = 120 / $this->fontsize;
     $this->lineheight = $this->fontsize * $this->linespacing;
     // Pull options from Yamlp2
     $this->title1 = $yamlP2['options']['title'];
     // Determine if there are filters to list:
     $uifilters = ArraySafe($yamlP2, 'uifilter', array());
     $atitle2 = array();
     foreach ($uifilters as $name => $info) {
         $atitle2[] = $info['description'] . ':' . trim(gp('ap_' . $name));
     }
     $this->title2 = count($atitle2) == 0 ? '' : implode(", ", $atitle2);
     // Tell the fpdf parent class about our setting choices
     $this->SetTextColor(0, 0, 0);
     $this->SetFont($this->fontname);
     $this->SetFontSize($this->fontsize);
     // Set up titles and columns by looping through and figuring
     // out justification and size
     $setupArr = array();
     $width = 0;
     foreach ($yamlP2['table'] as $table => $columns) {
         $dd = ddTable($table);
         foreach ($columns['column'] as $colname => $colinfo) {
             if (ArraySafe($colinfo, 'uino', 'N') == 'Y') {
                 continue;
             }
             $md = array('linkskey' => a($colinfo, 'linkskey', 'N'));
             // Use type to figure out if right or left
             // KFD 4/29/08, constants will not exist, use char
             if (!isset($dd['flat'][$colname]['type_id'])) {
                 $type_id = 'char';
             } else {
                 $type_id = $dd['flat'][$colname]['type_id'];
             }
             $suffix = '';
             if (in_array(trim($type_id), array('money', 'numb', 'int'))) {
                 $suffix .= ':R';
                 switch ($type_id) {
                     case 'money':
                         $scale = 2;
                         break;
                     case 'numb':
                         $scale = $dd['flat'][$colname]['colscale'];
                         break;
                     case 'int':
                         $scale = 0;
                 }
                 $suffix .= ':' . $scale;
             }
             if (trim($type_id) == 'money') {
                 $suffix .= ':M';
             }
             if (ArraySafe($colinfo, 'dispsize', '') != '') {
                 $suffix .= ':C' . $colinfo['dispsize'];
             }
             // Work out size using cpi setting
             $dispsize = ArraySafe($colinfo, 'dispsize', '');
             $dispsize = $dispsize != '' ? $dispsize : $dd['flat'][$colname]['dispsize'];
             $setupArr[] = round($dispsize / $this->cpi, 1) . $suffix;
             $width += $dispsize * $this->cpi + 0.1;
             // Save the captions for displaying in header
             $desc1 = a($dd['flat'][$colname], 'descshort', '');
             $desc2 = a($dd['flat'][$colname], 'description', '');
             $ddcaption = $desc1 != '' ? $desc1 : $desc2;
             $caption = ArraySafe($colinfo, 'description', '');
             $caption = $caption != '' ? $caption : $ddcaption;
             $this->captions[] = $caption;
             # Work out if this guy is a foreign key.  If they
             # have given a page then link unconditionally
             if (($tlink = a($colinfo, 'linkpage', '')) != '') {
                 $md['linkpage'] = $tlink;
                 $md['linkcolumn'] = $colname;
             } elseif ($dd['flat'][$colname]['primary_key'] == 'Y') {
                 if ($colname == $dd['pks']) {
                     $md['linkpage'] = $table;
                     $md['linkcolumn'] = $colname;
                 }
             } else {
                 $tfko = a($dd['flat'][$colname], 'table_id_fko', '');
                 if ($tfko != '') {
                     $ddpar = ddTable($tfko);
                     if ($tfko = $ddpar['pks']) {
                         $md['linkpage'] = $tfko;
                         $md['linkcolumn'] = $colname;
                     }
                 }
             }
             $this->md[] = $md;
         }
     }
     $this->setupColumns(0.1, implode(',', $setupArr));
     // Finally, establish orientation by looking at size of report
     if ($width / 72 < 7.5) {
         $this->orientation = 'P';
     } else {
         $this->orientation = 'L';
     }
 }
Example #10
0
function index_hidden_x6FETCH()
{
    $returns = array();
    # This is everything that *might* go back, make a place
    # for all of it
    $GLOBALS['AG']['x4'] = array('error' => array(), 'debug' => array(), 'notice' => array(), 'html' => array(), 'script' => array());
    // First fetch the values
    $table_id = gp('x6fetch');
    $dd = ddTable($table_id);
    $column = gp('x6col');
    $colvalue = gp('x6val');
    # Look for fetch columns that pull from this column's
    # table_id_fko
    $tfko = $dd['flat'][$column]['table_id_fko'];
    $cfko = $dd['flat'][$column]['column_id_fko'];
    $cols = array();
    foreach ($dd['flat'] as $fcol => $cdetails) {
        $arr = array('FETCH', 'FETCHDEF', 'DISTRIBUTE');
        if (in_array($cdetails['automation_id'], $arr)) {
            if ($cdetails['auto_table_id'] == $tfko) {
                $cols[$fcol] = $cdetails['auto_column_id'];
            }
        }
    }
    # We now have a list of source and destination
    # columns, build the query
    $sql = "Select " . implode(',', $cols) . " FROM {$tfko} WHERE {$cfko} = " . SQLFC($colvalue);
    $row = SQL_OneRow($sql);
    foreach ($cols as $fcol => $srccol) {
        $type = $dd['flat'][$fcol]['formshort'];
        if ($type == 'date') {
            x6html("x6inp_{$table_id}_{$fcol}", date("Y-m-d", dEnsureTs($row[$srccol])));
        } else {
            x6html("x6inp_{$table_id}_{$fcol}", $row[$srccol]);
        }
    }
    echo json_encode_safe($GLOBALS['AG']['x4']);
    exit;
}