| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
require_once("include/session.php"); |
|---|
| 40 |
require_once("include/search_class.php"); |
|---|
| 41 |
|
|---|
| 42 |
if(!isset($_GET["id"])) $error = new appError(100,"Passed Parameter not present."); |
|---|
| 43 |
$_GET["id"]= (integer) $_GET["id"]; |
|---|
| 44 |
|
|---|
| 45 |
$displayTable= new displaySearchTable($db); |
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
$displayTable->initialize($_GET["id"]); |
|---|
| 49 |
|
|---|
| 50 |
session_register("passedjoinclause"); |
|---|
| 51 |
session_register("passedjoinwhere"); |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
if(!isset($_POST["othercommands"])) $_POST["othercommands"]=""; |
|---|
| 56 |
if(!isset($_POST["relationship"])) $_POST["relationship"]=""; |
|---|
| 57 |
if(!isset($_POST["advancedsearch"])) $_POST["advancedsearch"]=""; |
|---|
| 58 |
if(!isset($_POST["advancedsort"])) $_POST["advancedsort"]=""; |
|---|
| 59 |
|
|---|
| 60 |
if(isset($_POST["doprint"])) |
|---|
| 61 |
if($_POST["doprint"] == "print") |
|---|
| 62 |
$_POST["command"]="print"; |
|---|
| 63 |
|
|---|
| 64 |
if(isset($_POST["deleteCommand"])) |
|---|
| 65 |
if($_POST["deleteCommand"]) $_POST["command"]=$_POST["deleteCommand"]; |
|---|
| 66 |
if($_POST["othercommands"]) $_POST["command"]="other"; |
|---|
| 67 |
if($_POST["relationship"]) $_POST["command"]="relate records"; |
|---|
| 68 |
if($_POST["advancedsearch"]) $_POST["command"]="advanced search"; |
|---|
| 69 |
if($_POST["advancedsort"]) $_POST["command"]="advanced sort"; |
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
if(isset($_POST["command"])){ |
|---|
| 73 |
|
|---|
| 74 |
switch($_POST["command"]){ |
|---|
| 75 |
|
|---|
| 76 |
case "print": |
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
$displayTable->querytype="print"; |
|---|
| 80 |
|
|---|
| 81 |
if($_POST["theids"] === "") |
|---|
| 82 |
$_POST["theids"]="-100"; |
|---|
| 83 |
|
|---|
| 84 |
$theids=explode(",",$_POST["theids"]); |
|---|
| 85 |
$_SESSION["printing"]["tableid"]=$displayTable->thetabledef["id"]; |
|---|
| 86 |
$_SESSION["printing"]["maintable"]=$displayTable->thetabledef["maintable"]; |
|---|
| 87 |
$_SESSION["printing"]["theids"]=$theids; |
|---|
| 88 |
goURL("print.php"); |
|---|
| 89 |
break; |
|---|
| 90 |
case "delete": |
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
$_POST["othercommands"] = -1; |
|---|
| 94 |
|
|---|
| 95 |
case "other": |
|---|
| 96 |
$displayTable->recordoffset=0; |
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
$theids=explode(",",$_POST["theids"]); |
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
if(file_exists("modules/".$displayTable->thetabledef["name"]."/include/".$displayTable->thetabledef["maintable"].".php")) |
|---|
| 103 |
include("modules/".$displayTable->thetabledef["name"]."/include/".$displayTable->thetabledef["maintable"].".php"); |
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
if(class_exists($displayTable->thetabledef["maintable"]."SearchFunctions")){ |
|---|
| 107 |
$classname = $displayTable->thetabledef["maintable"]."SearchFunctions"; |
|---|
| 108 |
$searchFunctions = new $classname($db,$displayTable->thetabledef["id"],$theids); |
|---|
| 109 |
} else |
|---|
| 110 |
$searchFunctions = new searchFunctions($db,$displayTable->thetabledef["id"],$theids); |
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
if(((int) $_POST["othercommands"]) === -1) |
|---|
| 114 |
$functionname = "delete_record"; |
|---|
| 115 |
else { |
|---|
| 116 |
$querystatement = "SELECT name FROM tableoptions WHERE id=".((int) $_POST["othercommands"]); |
|---|
| 117 |
$queryresult = $db->query($querystatement); |
|---|
| 118 |
$therecord = $db->fetchArray($queryresult); |
|---|
| 119 |
$functionname = $therecord["name"]; |
|---|
| 120 |
} |
|---|
| 121 |
|
|---|
| 122 |
if(method_exists($searchFunctions,$functionname)) |
|---|
| 123 |
$statusmessage = $searchFunctions->$functionname(); |
|---|
| 124 |
else |
|---|
| 125 |
$statusmessage = "Function ".$functionname." not defined"; |
|---|
| 126 |
|
|---|
| 127 |
break; |
|---|
| 128 |
case "search": |
|---|
| 129 |
$displayTable->recordoffset=0; |
|---|
| 130 |
$displayTable->buildSearch($_POST); |
|---|
| 131 |
break; |
|---|
| 132 |
case "reset": |
|---|
| 133 |
$displayTable->recordoffset=0; |
|---|
| 134 |
$displayTable->resetQuery(); |
|---|
| 135 |
break; |
|---|
| 136 |
case "omit": |
|---|
| 137 |
|
|---|
| 138 |
|
|---|
| 139 |
$displayTable->recordoffset=0; |
|---|
| 140 |
$tempwhere=""; |
|---|
| 141 |
$theids=explode(",",$_POST["theids"]); |
|---|
| 142 |
foreach($theids as $theid){ |
|---|
| 143 |
$tempwhere.=" or ".$displayTable->thetabledef["maintable"].".id=".$theid; |
|---|
| 144 |
} |
|---|
| 145 |
$tempwhere=substr($tempwhere,3); |
|---|
| 146 |
$displayTable->querywhereclause="(".$displayTable->querywhereclause.") and not (".$tempwhere.")"; |
|---|
| 147 |
break; |
|---|
| 148 |
case "keep": |
|---|
| 149 |
|
|---|
| 150 |
|
|---|
| 151 |
$displayTable->recordoffset=0; |
|---|
| 152 |
$tempwhere=""; |
|---|
| 153 |
$theids=explode(",",$_POST["theids"]); |
|---|
| 154 |
foreach($theids as $theid){ |
|---|
| 155 |
$tempwhere.=" or ".$displayTable->thetabledef["maintable"].".id=".$theid; |
|---|
| 156 |
} |
|---|
| 157 |
$tempwhere=substr($tempwhere,3); |
|---|
| 158 |
$displayTable->querywhereclause=$tempwhere; |
|---|
| 159 |
break; |
|---|
| 160 |
case "advanced search": |
|---|
| 161 |
$displayTable->recordoffset=0; |
|---|
| 162 |
$displayTable->querywhereclause=stripslashes($_POST["advancedsearch"]); |
|---|
| 163 |
$displayTable->querytype="advanced search"; |
|---|
| 164 |
break; |
|---|
| 165 |
case "advanced sort": |
|---|
| 166 |
$displayTable->showGroupings = 0; |
|---|
| 167 |
$displayTable->recordoffset = 0; |
|---|
| 168 |
$displayTable->querysortorder=$_POST["advancedsort"]; |
|---|
| 169 |
break; |
|---|
| 170 |
case "relate records": |
|---|
| 171 |
include("include/relationships.php"); |
|---|
| 172 |
$theids=explode(",",$_POST["theids"]); |
|---|
| 173 |
$goto=perform_relationship($_POST["relationship"],$theids); |
|---|
| 174 |
$_SESSION["temp_relateto"]=$displayTable->thetabledef["maintable"]; |
|---|
| 175 |
$displayTable->querytype="relate"; |
|---|
| 176 |
|
|---|
| 177 |
goURL($goto); |
|---|
| 178 |
break; |
|---|
| 179 |
|
|---|
| 180 |
} |
|---|
| 181 |
} |
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 |
if(!isset($_POST["newsort"])) $_POST["newsort"]=""; |
|---|
| 185 |
if(!isset($_POST["desc"])) $_POST["desc"]=""; |
|---|
| 186 |
|
|---|
| 187 |
if($_POST["newsort"]!="") { |
|---|
| 188 |
|
|---|
| 189 |
$displayTable->recordoffset=0; |
|---|
| 190 |
$displayTable->showGroupings = false; |
|---|
| 191 |
foreach ($displayTable->thecolumns as $therow){ |
|---|
| 192 |
if ($_POST["newsort"]==$therow["name"]) $therow["sortorder"]? $displayTable->querysortorder=$therow["sortorder"] : $displayTable->querysortorder=$therow["column"]; |
|---|
| 193 |
} |
|---|
| 194 |
$_POST["startnum"]=1; |
|---|
| 195 |
} elseif($_POST["desc"]!="") { |
|---|
| 196 |
|
|---|
| 197 |
$displayTable->showGroupings = false; |
|---|
| 198 |
$displayTable->querysortorder.=" DESC"; |
|---|
| 199 |
$displayTable->recordoffset=0; |
|---|
| 200 |
|
|---|
| 201 |
} |
|---|
| 202 |
|
|---|
| 203 |
if($displayTable->querytype!="print" and $displayTable->querytype!="relate" and $displayTable->querytype!="new" and $displayTable->querytype!="edit") { |
|---|
| 204 |
|
|---|
| 205 |
|
|---|
| 206 |
|
|---|
| 207 |
if(isset($_SESSION["passedjoinclause"])) { |
|---|
| 208 |
$displayTable->recordoffset=0; |
|---|
| 209 |
$displayTable->queryjoinclause=$_SESSION["passedjoinclause"]; |
|---|
| 210 |
session_unregister("passedjoinclause"); |
|---|
| 211 |
} |
|---|
| 212 |
|
|---|
| 213 |
|
|---|
| 214 |
|
|---|
| 215 |
if(isset($_SESSION["passedjoinwhere"])) { |
|---|
| 216 |
$displayTable->recordoffset=0; |
|---|
| 217 |
|
|---|
| 218 |
$displayTable->querywhereclause=$_SESSION["passedjoinwhere"]; |
|---|
| 219 |
session_unregister("passedjoinwhere"); |
|---|
| 220 |
|
|---|
| 221 |
|
|---|
| 222 |
$displayTable->querytype="related records from ".$_SESSION["temp_relateto"]; |
|---|
| 223 |
session_unregister("temp_relateto"); |
|---|
| 224 |
} |
|---|
| 225 |
|
|---|
| 226 |
|
|---|
| 227 |
if(isset($_POST["offset"])) if($_POST["offset"]!="") $displayTable->recordoffset=$_POST["offset"]; |
|---|
| 228 |
|
|---|
| 229 |
$displayTable->issueQuery(); |
|---|
| 230 |
|
|---|
| 231 |
$pageTitle = $displayTable->thetabledef["displayname"]; |
|---|
| 232 |
|
|---|
| 233 |
$phpbms->cssIncludes[] = "pages/search.css"; |
|---|
| 234 |
|
|---|
| 235 |
$phpbms->jsIncludes[] = "common/javascript/queryfunctions.js"; |
|---|
| 236 |
|
|---|
| 237 |
include("header.php"); |
|---|
| 238 |
|
|---|
| 239 |
?><div class="bodyline"> |
|---|
| 240 |
<h1 id="srchScreen<?php echo $displayTable->thetabledef["id"] ?>"><?php echo $displayTable->thetabledef["displayname"] ?></h1> |
|---|
| 241 |
<?php |
|---|
| 242 |
|
|---|
| 243 |
$displayTable->displaySearch(); |
|---|
| 244 |
$displayTable->displayQueryButtons(); |
|---|
| 245 |
|
|---|
| 246 |
$displayTable->displayResultTable(); |
|---|
| 247 |
|
|---|
| 248 |
$displayTable->displayRelationships(); |
|---|
| 249 |
|
|---|
| 250 |
$displayTable->saveQueryParameters(); |
|---|
| 251 |
?> |
|---|
| 252 |
</div> |
|---|
| 253 |
<?php include("footer.php");}?> |
|---|