| 39 | | if(!class_exists("phpbmsReport")) |
| 40 | | include("report_class.php"); |
| 41 | | |
| 42 | | class generalTablePrint extends phpbmsReport { |
| 43 | | |
| 44 | | var $maintable = ""; |
| 45 | | var $resultOutput = ""; |
| 46 | | var $tabledefuuid; |
| 47 | | |
| 48 | | function generalTablePrint($db, $tabledefuuid){ |
| 49 | | |
| 50 | | $this->tabledefuuid = mysql_real_escape_string($tabledefuuid); |
| 51 | | |
| 52 | | parent::phpbmsReport($db); |
| 53 | | |
| 54 | | $querystatement = " |
| 55 | | SELECT |
| 56 | | maintable, displayname |
| 57 | | FROM |
| 58 | | tabledefs |
| 59 | | WHERE |
| 60 | | uuid = '".$this->tabledefuuid."'"; |
| 61 | | |
| 62 | | $queryresult = $db->query($querystatement); |
| 63 | | $therecord=$db->fetchArray($queryresult); |
| 64 | | |
| 65 | | $this->maintable = $therecord["maintable"]; |
| 66 | | $this->displayname = $therecord["displayname"]; |
| 67 | | |
| 68 | | }//end method |
| 69 | | |
| 70 | | |
| 71 | | function generate(){ |
| 72 | | |
| 73 | | $querystatement = " |
| 74 | | SELECT |
| 75 | | * |
| 76 | | FROM |
| 77 | | ".$this->maintable; |
| 78 | | |
| 79 | | $querystatement = $this->assembleSQL($querystatement); |
| 80 | | |
| 81 | | $queryresult = $this->db->query($querystatement); |
| 82 | | |
| 83 | | $num_fields = $this->db->numFields($queryresult); |
| 84 | | |
| 85 | | ob_start(); |
| 86 | | |
| 87 | | ?> |
| 88 | | <div id="container"> |
| 89 | | <h1><?php echo formatVariable($this->displayname)?></h1> |
| 90 | | <table id="results"> |
| 91 | | <thead> |
| 92 | | <tr> |
| 93 | | <?php |
| 94 | | |
| 95 | | for($i=0;$i<$num_fields;$i++){ |
| 96 | | |
| 97 | | ?> |
| 98 | | <th <?php if($i == $num_fields-1) echo 'id="lastHeader"' ?>><?php echo $this->db->fieldName($queryresult, $i); ?></th> |
| 99 | | |
| 100 | | <?php |
| 101 | | |
| 102 | | }//end for |
| 103 | | |
| 104 | | ?> |
| 105 | | </tr> |
| 106 | | </thead> |
| 107 | | |
| 108 | | <tbody> |
| 109 | | <?php |
| 110 | | |
| 111 | | while($therecord = $this->db->fetchArray($queryresult)){ |
| 112 | | |
| 113 | | ?><tr><?php |
| 114 | | |
| 115 | | foreach($therecord as $value){ |
| 116 | | |
| 117 | | ?><td><?php echo formatVariable($value)?></td><?php |
| 118 | | |
| 119 | | }//end foreach |
| 120 | | |
| 121 | | ?></tr><?php |
| 122 | | |
| 123 | | }//endwhile |
| 124 | | |
| 125 | | ?> |
| 126 | | </tbody> |
| 127 | | |
| 128 | | </table> |
| 129 | | </div> |
| 130 | | <?php |
| 131 | | |
| 132 | | $this->reportOutput = ob_get_contents(); |
| 133 | | ob_end_clean(); |
| 134 | | |
| 135 | | }//end method |
| 136 | | |
| 137 | | |
| 138 | | function show(){ |
| 139 | | |
| 140 | | global $phpbms; |
| 141 | | $db = &$this->db; |
| 142 | | |
| 143 | | $phpbms->cssIncludes[] = "reports.css"; |
| 144 | | $phpbms->cssIncludes[] = "pages/generaltableprint.css"; |
| 145 | | |
| 146 | | $phpbms->showMenu = false; |
| 147 | | $phpbms->showFooter = false; |
| 148 | | |
| 149 | | include("header.php"); |
| 150 | | |
| 151 | | echo $this->reportOutput; |
| 152 | | |
| 153 | | include("footer.php"); |
| 154 | | |
| 155 | | }//end method |
| 156 | | |
| 157 | | }//end class |
| 158 | | |
| 159 | | |
| 160 | | //PROCESSING |
| 161 | | //======================================================================== |
| 162 | | |
| 163 | | if(!isset($noOutput)){ |
| 164 | | |
| 165 | | session_cache_limiter('private'); |
| 166 | | |
| 167 | | require("../include/session.php"); |
| 168 | | if(!isset($_GET["tid"])) |
| 169 | | $error = new appError(200,"URL variable missing: tid"); |
| 170 | | |
| 171 | | $report = new generalTablePrint($db, $_GET["tid"]); |
| 172 | | $report->setupFromPrintScreen(); |
| 173 | | $report->generate(); |
| 174 | | $report->show(); |
| 175 | | |
| 176 | | }//end if |
| | 39 | |
| | 40 | if(!class_exists("phpbmsReport")) |
| | 41 | include("report_class.php"); |
| | 42 | |
| | 43 | /** |
| | 44 | * Record Reporting in HTML table format |
| | 45 | * |
| | 46 | * This class implements a report used for printing out general table information |
| | 47 | * in HTML table format |
| | 48 | */ |
| | 49 | class generalTablePrint extends phpbmsReport { |
| | 50 | |
| | 51 | /** |
| | 52 | * $maintable |
| | 53 | * @var string the SQL name of the main table to print. |
| | 54 | */ |
| | 55 | var $maintable = ""; |
| | 56 | |
| | 57 | /** |
| | 58 | * $displayname |
| | 59 | * @var string display name of table definition |
| | 60 | */ |
| | 61 | var $displayname = ""; |
| | 62 | |
| | 63 | |
| | 64 | /** |
| | 65 | * function generalTablePrint |
| | 66 | * |
| | 67 | * Initialization function |
| | 68 | * |
| | 69 | * @param object $db database object |
| | 70 | * @param string $reportUUID UUID of report record |
| | 71 | * @param string $tabledefUUID UUID of table definition intializing print |
| | 72 | */ |
| | 73 | function generalTablePrint($db, $reportUUID, $tabledefUUID){ |
| | 74 | |
| | 75 | parent::phpbmsReport($db, $reportUUID, $tabledefUUID); |
| | 76 | |
| | 77 | $therecord = $this->getTableDefInfo(); |
| | 78 | |
| | 79 | $this->maintable = $therecord["maintable"]; |
| | 80 | $this->displayname = $therecord["displayname"]; |
| | 81 | |
| | 82 | }//end function init |
| | 83 | |
| | 84 | |
| | 85 | /** |
| | 86 | * function generate |
| | 87 | * |
| | 88 | * Creates the main part of the report (table) |
| | 89 | */ |
| | 90 | function generate(){ |
| | 91 | |
| | 92 | $fromFields = "*"; |
| | 93 | |
| | 94 | $columns = array(); |
| | 95 | foreach($this->settings as $key=>$value){ |
| | 96 | |
| | 97 | if(strpos($key, "column") === 0){ |
| | 98 | |
| | 99 | $pos = substr($key,6)-1; |
| | 100 | $columns[$pos]["field"] = $value; |
| | 101 | |
| | 102 | if(isset($this->settings["titleColumn".($pos + 1)])) |
| | 103 | $columns[$pos]["title"] = $this->settings["titleColumn".($pos +1)]; |
| | 104 | else |
| | 105 | $columns[$pos]["title"] = ""; |
| | 106 | |
| | 107 | }//endif |
| | 108 | |
| | 109 | }//endforeach |
| | 110 | |
| | 111 | if(count($columns)){ |
| | 112 | |
| | 113 | ksort($columns); |
| | 114 | $columns = array_reverse($columns); |
| | 115 | |
| | 116 | $fromFields = ""; |
| | 117 | foreach($columns as $column){ |
| | 118 | |
| | 119 | $fromFields .= ", ".$column["field"]; |
| | 120 | if($column["title"]) |
| | 121 | $fromFields .= " AS `".$column["title"]."`"; |
| | 122 | |
| | 123 | $fromFields.="\n"; |
| | 124 | |
| | 125 | }//endforeach |
| | 126 | |
| | 127 | $fromFields = substr($fromFields, 1); |
| | 128 | |
| | 129 | }//endif |
| | 130 | |
| | 131 | if(isset($this->settings["fromTable"])) |
| | 132 | $querytable = $this->settings["fromTable"]; |
| | 133 | else |
| | 134 | $querytable = $this->maintable; |
| | 135 | |
| | 136 | $querystatement = " |
| | 137 | SELECT |
| | 138 | ".$fromFields." |
| | 139 | FROM |
| | 140 | ".$querytable; |
| | 141 | |
| | 142 | $querystatement = $this->assembleSQL($querystatement); |
| | 143 | |
| | 144 | $queryresult = $this->db->query($querystatement); |
| | 145 | |
| | 146 | $num_fields = $this->db->numFields($queryresult); |
| | 147 | |
| | 148 | |
| | 149 | if(!isset($this->settings["reportTitle"])) |
| | 150 | $this->settings["reportTitle"] = $this->displayname; |
| | 151 | |
| | 152 | ob_start(); |
| | 153 | |
| | 154 | ?> |
| | 155 | <div id="container"> |
| | 156 | <h1><?php echo formatVariable($this->settings["reportTitle"])?></h1> |
| | 157 | <table id="results"> |
| | 158 | <thead> |
| | 159 | <tr> |
| | 160 | <?php |
| | 161 | |
| | 162 | for($i=0;$i<$num_fields;$i++){ |
| | 163 | |
| | 164 | ?> |
| | 165 | <th <?php if($i == $num_fields-1) echo 'id="lastHeader"' ?>><?php echo $this->db->fieldName($queryresult, $i); ?></th> |
| | 166 | <?php |
| | 167 | |
| | 168 | }//end for |
| | 169 | |
| | 170 | ?> |
| | 171 | </tr> |
| | 172 | </thead> |
| | 173 | |
| | 174 | <tbody> |
| | 175 | <?php |
| | 176 | |
| | 177 | while($therecord = $this->db->fetchArray($queryresult)){ |
| | 178 | |
| | 179 | ?><tr><?php |
| | 180 | |
| | 181 | foreach($therecord as $value){ |
| | 182 | |
| | 183 | ?><td><?php echo formatVariable($value)?></td><?php |
| | 184 | |
| | 185 | }//end foreach |
| | 186 | |
| | 187 | ?></tr><?php |
| | 188 | |
| | 189 | }//endwhile |
| | 190 | |
| | 191 | ?> |
| | 192 | </tbody> |
| | 193 | </table> |
| | 194 | </div> |
| | 195 | <?php |
| | 196 | |
| | 197 | $this->reportOutput = ob_get_contents(); |
| | 198 | ob_end_clean(); |
| | 199 | |
| | 200 | }//end function generate |
| | 201 | |
| | 202 | |
| | 203 | /** |
| | 204 | * function show |
| | 205 | * |
| | 206 | * outputs HTML report |
| | 207 | */ |
| | 208 | function show(){ |
| | 209 | |
| | 210 | global $phpbms; |
| | 211 | $db = &$this->db; |
| | 212 | |
| | 213 | $phpbms->cssIncludes[] = "reports.css"; |
| | 214 | $phpbms->cssIncludes[] = "pages/generaltableprint.css"; |
| | 215 | |
| | 216 | $phpbms->showMenu = false; |
| | 217 | $phpbms->showFooter = false; |
| | 218 | |
| | 219 | include("header.php"); |
| | 220 | |
| | 221 | echo $this->reportOutput; |
| | 222 | |
| | 223 | include("footer.php"); |
| | 224 | |
| | 225 | }//end method |
| | 226 | |
| | 227 | }//end class |
| | 228 | |
| | 229 | |
| | 230 | /** |
| | 231 | * PROCESSING |
| | 232 | * ============================================================================= |
| | 233 | */ |
| | 234 | if(!isset($noOutput)){ |
| | 235 | |
| | 236 | session_cache_limiter('private'); |
| | 237 | |
| | 238 | require_once("../include/session.php"); |
| | 239 | |
| | 240 | checkForReportArguments(); |
| | 241 | |
| | 242 | $report = new generalTablePrint($db, $_GET["rid"], $_GET["tid"]); |
| | 243 | $report->setupFromPrintScreen(); |
| | 244 | $report->generate(); |
| | 245 | $report->show(); |
| | 246 | |
| | 247 | }//end if |
| | 248 | |
| | 249 | /** |
| | 250 | * When adding a new report record, the add/edit needs to know what the class |
| | 251 | * name is so that it can instantiate it, and grab it's default settings. |
| | 252 | */ |
| | 253 | if(isset($addingReportRecord)) |
| | 254 | $reportClass ="generalTablePrint"; |