navigation  interaction  search

 other resources

root/tags/phpbms-0.51/print.php

Revision 1 (checked in by mipalmer, 2 years ago)

--

Line 
1 <?php
2 require_once("include/session.php");
3 require_once("include/print_class.php");
4
5 $pageTitle="Print/Export";
6
7 if(!isset($_GET["backurl"])) $_GET["backurl"]="";
8 if(isset($_POST["backurl"])) $_GET["backurl"]=$_POST["backurl"];
9
10 $tablePrinter= new printer;
11 $tablePrinter->initialize($_SESSION["printing"]["tableid"],$_SESSION["printing"]["theids"]);
12
13 $tablePrinter->saveVariables();
14
15 if (isset($_POST["command"])){
16     switch($_POST["command"]){
17         case "done":
18             $tablePrinter->donePrinting($_GET["backurl"]);
19         break;
20         case "print":
21             //let's build the whereclause
22             $whereclause="";
23             $dataprint="";
24             switch($_POST["therecords"]){
25                 case "all":
26                     $dataprint="All Records";
27                 break;
28                 case "savedsearch":
29                     if($_POST["savedsearches"]!="" and $_POST["savedsearches"]!="NA")    {
30                         $querystatement="SELECT name,sqlclause FROM usersearches WHERE id=".$_POST["savedsearches"];
31                         $queryresult=mysql_query($querystatement,$dblink);
32                         If(!$queryresult) reportError(500,"Could not retrieve saved search. ".$querystatement);
33                         $therecord=mysql_fetch_array($queryresult);
34                         $whereclause="WHERE ".$therecord["sqlclause"];
35                         $dataprint=$therecord["name"];
36                     }
37                 break;
38                 case "selected":
39                     foreach($tablePrinter->theids as $theid){
40                         $whereclause.=" or ".$tablePrinter->maintable.".id=".$theid;
41                     }
42                     $whereclause="where ".substr($whereclause,3);
43                     $dataprint="Selected Records";
44                 break;
45             }           
46             $_SESSION["printing"]["whereclause"]=$whereclause;
47             $_SESSION["printing"]["dataprint"]=$dataprint;
48             
49             //next let's do the sort
50             $sortorder="";
51             switch($_POST["thesort"]){
52                 case "single":
53                     $sortorder=" ORDER BY ".$tablePrinter->maintable.".".$_POST["singlefield"]." ".$_POST["order"];
54                 break;
55                 case "savedsort":
56                     if($_POST["savedsorts"]!="" and $_POST["savedsorts"]!="NA")    {
57                         $querystatement="SELECT sqlclause FROM usersearches WHERE id=".$_POST["savedsorts"];
58                         $queryresult=mysql_query($querystatement,$dblink);
59                         If(!$queryresult) reportError(500,"Could not retrieve saved search. ".$querystatement);
60                         $therecord=mysql_fetch_array($queryresult);
61                         $sortorder=" ORDER BY ".$therecord["sqlclause"];
62                     }
63                 break;
64             }
65             $_SESSION["printing"]["sortorder"]=$sortorder;
66             
67             if(isset($_POST["choosereport"])){
68                 $tablePrinter->openwindows="<script language=\"JavaScript\">\n";
69                 for($i=0;$i<count($_POST["choosereport"]);$i++){
70                     if($_POST["choosereport"][$i]){
71                         $querystatement="SELECT reportfile from reports where id=".$_POST["choosereport"][$i].";";
72                         $queryresult=mysql_query($querystatement,$dblink);
73                         if(!$queryresult) reportError(100,"Could not Retreive Report Information");               
74                         $reportrecord=mysql_fetch_array($queryresult);   
75                         //javascript open each report in new window
76                         $tablePrinter->openwindows.="window.open('".$_SESSION["app_path"].$reportrecord["reportfile"]."?tabledefid=".urlencode($tablePrinter->tableid)."','print".$i."');\n";
77                     }
78                 }
79                 $tablePrinter->openwindows.="</script>\n";
80             }           
81         break;
82     }
83 }
84 ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
85 <html>
86 <head>
87 <title><?php echo $pageTitle ?></title>
88 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
89 <link href="common/stylesheet/<?php echo $_SESSION["stylesheet"] ?>/base.css" rel="stylesheet" type="text/css">
90 <script language="JavaScript" src="common/javascript/print.js"></script>
91 <?PHP  $tablePrinter->showJavaScriptArray();?>
92
93 </head>
94 <body>
95 <?PHP     if($tablePrinter->openwindows) echo "\n".$tablePrinter->openwindows; ?>
96 <div class="bodyline" style="width:550px;margin-top:2px;">
97     <div class="searchtitle"><?php echo $pageTitle ?></div>
98    
99 <form action="print.php" method="post" name="print">
100     <input type="hidden" name="backurl" value="<?php echo $_GET["backurl"]?>">
101     <div class=box>
102         <div style="float:right;width:320px;">
103             <?PHP mysql_data_seek($tablePrinter->reports,0); $therecord=mysql_fetch_array($tablePrinter->reports) ?>
104                     <div>
105                         <strong>report information</strong><br>
106                         report name<br>
107                         <input name="reportid" type="hidden" value="<?PHP echo $therecord["id"] ?>">
108                         <input name="reportfile" type="hidden" value="<?PHP echo $therecord["reportfile"] ?>">
109                         <input name="name" type="text" class="uneditable" id="name" style="font-weight:bold; width:100%" value="<?PHP echo $therecord["name"] ?>" size="32" maxlength="64" readonly="true">
110                     </div>
111                     <div>
112                         report type<br>
113                         <input name="type" type="text" class="uneditable" id="type" value="<?PHP echo $therecord["type"] ?>" size="20" maxlength="64" readonly="true" style="width:100%">
114                     </div>
115                     <div>
116                        description<br>
117                        <textarea name="description" cols="45" rows="3" readonly="readonly" id="description" style="width:100%" class="uneditable"><?PHP echo stripcslashes($therecord["description"]) ?></textarea>
118                     </div>       
119         </div>
120         <div style="margin-right:320px;">
121             <strong>select report(s)</strong><br><?php $tablePrinter->displayReportList()?>
122         </div>
123     </div>
124    
125     <div class="box">
126             <div id="showsavedsearches" style="display:none;float:right;width:320px">
127                 load saved search...<br>
128                 <?php $tablePrinter->showSaved($tablePrinter->savedSearches,"savedsearches");?>
129             </div>
130             <div style="">
131             <strong>choose data to print</strong><br>           
132             <select name="therecords" onChange="showSavedSearches(this);" style="width:200px;">
133                 <option value="selected">selected records (<?php echo count($tablePrinter->theids) ?> record<?php if(count($tablePrinter->theids)>1) echo "s"?>)</option>
134                 <option value="savedsearch">saved search...</option>
135                 <option value="all">all records in table</option>
136             </select>
137             </div>
138     </div>
139     <div class="box">
140         <div id="savedsortdiv" style="display:none;float:right;width:320px;">
141             use saved sort...<br>
142             <?php $tablePrinter->showSaved($tablePrinter->savedSorts,"savedsorts");?>
143         </div>
144         <div id="singlesortdiv" style="display:none;float:right;width:320px;">
145             sort by field<br>
146             <?php $tablePrinter->showFieldSort()?>
147             <select name="order">
148                 <option value="ASC" selected>Ascending</option>
149                 <option value="DESC">Descending</option>
150             </select>           
151         </div>
152         <div style="">
153             <strong>sort options</strong><br>
154             <select name="thesort" onChange="showSortOptions(this)" style="width:200px;">
155                 <option value="default" selected>report default</option>
156                 <option value="single">single field</option>
157                 <option value="savedsort">saved sort...</option>
158             </select>
159         </div>
160     </div>
161
162     <div align="right" class="recordbottom">
163      <input name="command" type="submit" class="Buttons" id="print" value="print" style="width:75px;margin-right:3px;">
164      <input name="command" type="submit" class="Buttons" id="cancel" value="done" style="width:75px;">     
165      </div>
166    </form>
167 </div>
168 </body>
169 </html>
Note: See TracBrowser for help on using the browser.
Copyright © 2006-2007 Kreotek, LLC. All Rights reserved.