/** * Pull all apps out of the server and then examine * the local station for latest versions * */ function svnVersions() { // Get a list of applications $sq = "SELECT skey,application,description\n ,svn_url\n ,' ' as local\n ,' ' as latest\n ,svn_uid,svn_pwd,flag_svn\n FROM applications\n WHERE flag_svn = 'Y'\n ORDER by application"; $rows = SQL_Allrows($sq, 'application'); // Get latest pkg-apps entries $dir = fsDirTop() . 'pkg-apps/'; if (!file_exists($dir)) { mkdir($dir); } $vdirs = scandir($dir); foreach ($vdirs as $vdir) { if ($vdir == '.') { continue; } if ($vdir == '..') { continue; } if (strpos($vdir, '-VER-') === false) { continue; } // split into app and version list($app, $vers) = explode('-VER-', $vdir); if (isset($rows[$app])) { $rows[$app]['local'] = max($rows[$app]['local'], $vers); } } return $rows; }
/** 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; }
function ehTab_Filters($ajax = true) { if ($ajax) { echo "x2_content|"; } $skey = SQLFN(gp('gp_skey')); $report = SQL_OneValue('report', "Select report from reports where skey={$skey}"); // Do any processing that may have come through if (gp('gp_ajax') == 'filtrep') { $repfilters = SQLFC(gp('gp_val')); //echo "we are setting $repfilters"; SQL("UPDATE reports SET repfilters={$repfilters} WHERE skey={$skey}"); } if (gp('gp_ajax') == 'filtlev') { $repfilters = SQLFC(gp('gp_val')); $skeylev = SQLFN(gp('gp_skeylev')); SQL("UPDATE reportlevels \n SET repfilters={$repfilters} WHERE skey={$skeylev}"); } // Retrieve and display $repfilter = SQL_OneValue('repfilters', "Select skey,repfilters from reports where skey={$skey}"); $levs = SQL_AllRows("Select rl.skey,rl.reportlevel,rl.repfilters \n from reportlevels rl\n WHERE exists ( SELECT * from reportcollevels\n WHERE report = '{$report}'\n AND reportlevel = rl.reportlevel)\n AND report='{$report}'"); //echo hErrors(); // Now for each level list some filters ?> <table> <tr> <td class="dhead" style="width: 10em">Level</td> <td class="dhead">SQL Filters</td> <td class="dhead">Save</td> </tr> <tr> <td valign=top>Base</td> <td><textarea id='lev0' name="lev0" cols=60 rows=5 style="border:1px solid gray" ><?php echo $repfilter; ?> </textarea></td> <td><a href="javascript:sndReq('&gp_ajax=filtrep&gp_val='+encodeURIComponent(ob('lev0').value))">Save</a> </tr> <?php foreach ($levs as $lev) { $js = '&gp_ajax=filtlev&gp_skeylev=' . $lev['skey']; ?> <tr> <td valign=top><?php echo $lev['reportlevel']; ?> </td> <td><textarea cols=60 rows=5 style="border:1px solid gray" onchange="sndReq('<?php echo $js; ?> &gp_val='+this.value)" ><?php echo $lev['repfilters']; ?> </textarea></td> </tr> <?php } ?> </table> <br/> <h3>Columns in this report</h3> <table style="width:50%"> <tr> <td class="dhead">Description</td> <td class="dhead">Table</td> <td class="dhead">Column</td> </tr> <?php // Columns in this report $sql = "SELECT description,table_id,column_id from reportcolumns\n WHERE report = '{$report}'\n ORDER BY description"; $cols = SQL_Allrows($sql); foreach ($cols as $col) { ?> <tr><td><?php echo $col['description']; ?> <td><?php echo $col['table_id']; ?> <td><?php echo $col['column_id']; ?> <?php } ?> </table> <?php }