function qList($var, $dyn) { //echo "<p>SQL:\n"; $sql = $this->fetchQuery($var); //echo "$sql</p>\n"; $xSet = 'XSet' . $dyn; echo "<p id=\"{$xSet}\"><strong>", $this->getVarTitle($var), "</strong>\n"; hiddenInput('VarX' . $dyn, $var); if ($dyn > 1) { radioInput('BoolX' . $dyn, 'AND'); echo "AND\n"; radioInput('BoolX' . $dyn, 'OR'); echo "OR\n"; } if ($sql) { $rX = $this->xQuery($sql, 1); selectFromQuery($rX, 'SelX' . $dyn, $this->getQParmName($var, 'key'), '', $this->getQParmName($var, 'var'), '', '', ''); killResult($rX); } else { $arOpts = $this->getItemOpts($var); if ($arOpts['dated']) { $currTime = time(); $dayOfWeek = date('N', $t); if ($dayOfWeek > 6) { $dayOfWeek = 0; } $Sunday = $currTime - 24 * 3600 * $dayOfWeek; $nextSunday = $currTime + (7 - $dayOfWeek) * 24 * 3600; $Saturday = 6 * 24 * 3600 + $Sunday; $nextSaturday = 6 * 24 * 3600 + $nextSunday; $thisMonth = date('Y-m-01', $currTime) . '_' . date('Y-m-t', $currTime); $thisWeek = date('Y-m-d', $Sunday) . '_' . date('Y-m-d', $Saturday); $nextWeek = date('Y-m-d', $nextSunday) . '_' . date('Y-m-d', $nextSaturday); $today = date('Y-m-d'); selectFromArray('SelX' . $dyn, array("__lt{$today}", "__eq{$today}", "__rg{$thisWeek}", "__rg{$nextWeek}", "__rg{$thisMonth}", "__gt{$today}"), '', array('Before today', 'Today', 'This week', 'Next week', 'This month', 'After today'), '', '', ''); } elseif ($arOpts['specify']) { echo " like <input type=\"text\" id=\"SelX{$dyn}\" name =\"SelX{$dyn}\" size=\"16\" />\n"; } else { selectFromArray('SelX' . $dyn, '', '', explode('\\t', $arOpts['values']), '', '', ''); } } echo "<span style=\"color: #600;\" onClick=\"removeOpt('{$dyn}');\" >Scratch</span>\n"; echo "</p>\n"; }
textInput($key, $value); break; case 'start_date': textInput($key, $value, true); break; case 'desc': textInput($key, $value); break; // case 'date': // textInput($key , $value, true); // break; // case 'date': // textInput($key , $value, true); // break; case 'id': hiddenInput($key, $value); break; } } ?> <input type="hidden" name="processing" value="true"></input> <button type="submit" class="btn btn-secondary-outline btn-block m-b-md"><i class="fa fa-save"></i> Save Changes</button> </form> <script type="text/javascript"> $(function(){ // init datepicker
function fileInput($name, $size, $multi) { hiddenInput('MAX_FILE_SIZE', $size); echo "<input type=\"file\" name=\"{$name}\" id=\"z_{$name}\" "; if ($multi) { echo "multiple "; } echo "/>\n"; }
function createExportQuery($allVars, $thisFileName) { echo "<p>Creating query...</p>\n"; reset($_REQUEST); $iMax = 0; $whereClause = ''; $chosenOnes = array(); foreach ($_REQUEST as $varX => $valX) { if (strpos($varX, 'VarX') !== false) { $i = substr($varX, 4); $iMax = max($iMax, $i); if ($whereClause) { $whereClause .= $_REQUEST['BoolX' . $i]; } $whereClause .= ' ' . $valX . "='" . $_REQUEST['SelX' . $i] . "' "; //$whereClause.=' ('.fillClause($valX,$_REQUEST['SelX'.$i]).') '; } elseif (strpos($varX, 'FLD') !== false) { $chosenOnes[] = $valX; } } $chosenString = $_REQUEST['allvars'] == 'ALL' ? implode(',', $allVars) : implode(',', $chosenOnes); if ($whereClause) { echo "<p>{$whereClause}</p>\n"; $sql = "SELECT {$chosenString} FROM grants WHERE active>0 AND ({$whereClause}) "; //echo "<p>$sql</p>\n"; } else { echo "<p><strong style=\"color: #090;\">Note: all records will be used in query</strong></p>\n"; $sql = "SELECT {$chosenString} FROM grants WHERE active>0"; } if ($sql) { echo "<p><strong>Query generated:</strong></p>\n"; //echo "<p>$sql</p>\n"; echo "<p><strong>Display in new window as HTML or download XLS</strong>\n"; echo "<form action=\"http://www.tfrec.wsu.edu/QinWindow.php\" ", "method=\"POST\" target=\"_exportDB\" >"; hiddenInput('caller', $thisFileName); hiddenInput('varlist', $chosenString); hiddenInput('where', $whereClause ? 'WHERE ' . $whereClause : ''); closeForm('HTML', '', 'XLS'); } }