initialize($_SESSION["printing"]["tableid"],$_SESSION["printing"]["theids"]); $tablePrinter->saveVariables(); if (isset($_POST["command"])){ switch($_POST["command"]){ case "done": $tablePrinter->donePrinting($_GET["backurl"]); break; case "print": //let's build the whereclause $whereclause=""; $dataprint=""; switch($_POST["therecords"]){ case "all": $dataprint="All Records"; break; case "savedsearch": if($_POST["savedsearches"]!="" and $_POST["savedsearches"]!="NA") { $querystatement="SELECT name,sqlclause FROM usersearches WHERE id=".$_POST["savedsearches"]; $queryresult=mysql_query($querystatement,$dblink); If(!$queryresult) reportError(500,"Could not retrieve saved search. ".$querystatement); $therecord=mysql_fetch_array($queryresult); $whereclause="WHERE ".$therecord["sqlclause"]; $dataprint=$therecord["name"]; } break; case "selected": foreach($tablePrinter->theids as $theid){ $whereclause.=" or ".$tablePrinter->maintable.".id=".$theid; } $whereclause="where ".substr($whereclause,3); $dataprint="Selected Records"; break; } $_SESSION["printing"]["whereclause"]=$whereclause; $_SESSION["printing"]["dataprint"]=$dataprint; //next let's do the sort $sortorder=""; switch($_POST["thesort"]){ case "single": $sortorder=" ORDER BY ".$tablePrinter->maintable.".".$_POST["singlefield"]." ".$_POST["order"]; break; case "savedsort": if($_POST["savedsorts"]!="" and $_POST["savedsorts"]!="NA") { $querystatement="SELECT sqlclause FROM usersearches WHERE id=".$_POST["savedsorts"]; $queryresult=mysql_query($querystatement,$dblink); If(!$queryresult) reportError(500,"Could not retrieve saved search. ".$querystatement); $therecord=mysql_fetch_array($queryresult); $sortorder=" ORDER BY ".$therecord["sqlclause"]; } break; } $_SESSION["printing"]["sortorder"]=$sortorder; if(isset($_POST["choosereport"])){ $tablePrinter->openwindows="\n"; } break; } } ?>