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"; }
function manageListing($thisFileName, $idAr, $varOrder) { $gofor = $_REQUEST['gofor']; if ($gofor == 'Submit') { $gofor = 'Insert'; } $indx = $this->getIndx(); $idName = $this->getDisplayText(); $colInfo = $this->getItemInfo(); $rIndx = $this->getRIndx($gofor, 'indx'); if (!$gofor and $rIndx) { $gofor = 'Edit'; } $hiddenVars = $idAr ? $idAr : array(); if ($rIndx) { $ar = $this->getDbRow($rIndx); $varName = $this->getDisplayText(); echo "<p><strong>Editing data for ", $ar["{$varName}"], "</strong></p>\n"; $hiddenVars['indx'] = $rIndx; } else { //$hiddenVars=array(); } //echo "<p>Looking for gofor=*$gofor* with index=*$rIndx*; part=", //URLParts(1),"</p>\n"; if ($gofor) { if ($gofor == 'Delete?') { $this->cmsForm('Delete ' . $ar["{$idName}"] . ' (are you sure)', '', $thisFileName, 'POST', '1', 'OK, Delete', $hiddenVars); $this->cmsForm('NO ', '', $thisFileName, 'POST', '1', 'Cancel', ''); } else { if ($gofor == 'OK, Delete') { $nid = $this->deleteObs($rIndx); $ar = array(); $rIndx = 0; } else { if ($gofor == 'Update' or $gofor == 'Insert' or $gofor == 'Continue' or $gofor == 'Replace' or $gofor == 'Include' or $gofor == 'Duplicate') { $varlist = array_diff(array_keys($colInfo), array($indx)); $vars = arrayFromInput($varlist, '1', ''); if ($this->arTextFlds) { $this->removeParaMarks($vars); } if ($ckVar = $this->checkDuplicate() and ($gofor == 'Insert' or $gofor == 'Duplicate') and $cIndx = getValueFromDB($this->tabl, $this->indx, array($ckVar => $vars["{$ckVar}"]))) { echo "<p><strong>Warning ({$cIndx}): {$ckVar} = ", $vars["{$ckVar}"], " exists in database</strong></p>\n"; echo "<p>Choose <strong>Replace</strong> to Overwrite entry<br />", "or <strong>Continue</strong> to add as an ", "additional entry with or without further changes</p>\n"; $disp = 'Continue'; $ar = $vars; $hiddenVars['indx'] = $cIndx; } elseif ($gofor == 'Include') { $ar = $vars; } else { if ($gofor == 'Update' or $gofor == 'Replace') { $nid = $this->updateObs($rIndx, $vars); echo "<!-- Ready to notify -->\n"; $this->updNotify($vars); } elseif ($gofor == 'Insert' or $gofor == 'Continue' or $gofor == 'Duplicate') { $rIndx = $this->createObs($vars); $hiddenVars['indx'] = $rIndx; } $ar = $this->getDbRow($rIndx); } } } } if ($gofor == 'Edit' or $gofor == 'Update' or $gofor == 'Insert' or $gofor == 'Add' or $gofor == 'Continue' or $gofor == 'Replace' or $gofor == 'Include' or $gofor == 'Duplicate') { $disp2 = ''; if ($gofor == 'Add' or $gofor == 'Include') { $disp = 'Insert'; $this->upLoadButton(); } elseif ($disp == 'Continue') { $disp2 = 'Replace'; } else { $disp = 'Update'; $disp2 = 'Duplicate'; $this->cmsForm('Delete this entry', '', $thisFileName, 'POST', '1', 'Delete?', $hiddenVars); } echo "<p> </p>\n"; echo $this->closerButton($rIndx); $this->cmsForm('', $this->formid, $thisFileName, 'POST', '', '', $hiddenVars); //echo "<p>Checkpoint</p>\n"; //echo "<p>There are ",sizeof($colInfo)," items</p>\n"; $this->fillFields(); foreach ($colInfo as $key => $val) { if ($key != $indx) { echo $this->formItem($val, $key, $ar["{$key}"]); } //!$indx } //$cols echo "<p> </p>\n"; closeForm($disp, 'Reset', $disp2); } echo "<hr />\n"; $strng = "Edit another entry"; } else { $strng = "Edit this entry"; } $hiddenVars = $idAr ? $idAr : array(); $this->cmsForm('', 'editThisEntry', $thisFileName, 'POST', '', '', $hiddenVars); echo "<p><strong>{$strng}</strong></p>\n"; if ($this->xQueryInfo) { $this->extendedBrowse(); } $rowList = $this->getRowList(); echo "<p><strong>View list as </strong>"; radioInputWScript('pullTabl', 'pull', 1, "togglePullTabl('viewAsPopup','viewAsTable')"); echo "Pull-down\n"; radioInputWScript('pullTabl', 'tabl', 0, "togglePullTabl('viewAsTable','viewAsPopup')"); echo "Table</p>\n"; echo "<div id=\"editList\">\n"; echo "<p id=\"viewAsPopup\">"; //selectFromArray('indx',array_keys($rowList),'', // array_values($rowList),'--','',''); selectFromArray('indx', array_keys($rowList), '', cImplode(':', array_values($rowList), 30, 5, 'array'), '--', '', ''); echo "</p>\n"; echo "<table id=\"viewAsTable\" style=\"display: none\" " . "border=\"1\" width=\"100%\">\n"; $i = 1; echo "<tr><td>"; addGofor('Edit'); echo "</td></tr>\n"; foreach ($rowList as $k => $rLine) { $tar = explode(':', $rLine); echo "<tr>"; echo "<td><input type=\"radio\" name=\"alt_indx\" ", "onClick=\"tookie({$i},'indx','editThisEntry');\" /></td>"; foreach ($tar as $rItem) { echo "<td>{$rItem}</td>"; } echo "</tr>\n"; $i++; } echo "</table>\n"; echo "</div>\n"; echo "<p>"; //hiddenInput('gofor','Edit'); closeForm('Edit', '', ''); pg_free_result($r); echo "<p><strong>OR</strong></p>\n"; $this->cmsForm('Add an entry', '', $thisFileName, 'POST', '1', 'Add', $hiddenVars); return 1; }