phpBMS

root/branches/nathan/print.php

Revision 311, 10.3 KB (checked in by brieb, 5 years ago)

Added initial accounts receivable system.
Fixed IE 6 & 7 discrepencies.
Fixed several windows server problems.
Started conversion of new JavaScript? system.

Problems that still (may) exist:
Installers untested (updaters tested)
IE/Opera Javascript bugs may exist.
nl_langinfo still in system (bad for windows servers)

  • Property svn:keywords set to LastChangedBy LastChangedDate LastChangedRevision
Line 
1<?php
2/*
3 $Rev$ | $LastChangedBy$
4 $LastChangedDate$
5 +-------------------------------------------------------------------------+
6 | Copyright (c) 2004 - 2007, Kreotek LLC                                  |
7 | All rights reserved.                                                    |
8 +-------------------------------------------------------------------------+
9 |                                                                         |
10 | Redistribution and use in source and binary forms, with or without      |
11 | modification, are permitted provided that the following conditions are  |
12 | met:                                                                    |
13 |                                                                         |
14 | - Redistributions of source code must retain the above copyright        |
15 |   notice, this list of conditions and the following disclaimer.         |
16 |                                                                         |
17 | - Redistributions in binary form must reproduce the above copyright     |
18 |   notice, this list of conditions and the following disclaimer in the   |
19 |   documentation and/or other materials provided with the distribution.  |
20 |                                                                         |
21 | - Neither the name of Kreotek LLC nor the names of its contributore may |
22 |   be used to endorse or promote products derived from this software     |
23 |   without specific prior written permission.                            |
24 |                                                                         |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS     |
26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT       |
27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
28 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT      |
29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   |
30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT        |
31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,   |
32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY   |
33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT     |
34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE   |
35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.    |
36 |                                                                         |
37 +-------------------------------------------------------------------------+
38*/
39require_once("include/session.php");
40require_once("include/print_class.php");
41
42if(!isset($_GET["backurl"])) $_GET["backurl"]="";
43if(isset($_POST["backurl"])) $_GET["backurl"]=$_POST["backurl"];
44
45$tablePrinter= new printer($db,$_SESSION["printing"]["tableid"],$_SESSION["printing"]["theids"]);
46
47$tablePrinter->saveVariables();
48
49if (isset($_POST["command"])){
50        switch($_POST["command"]){
51                case "done":
52                        $tablePrinter->donePrinting($_GET["backurl"]);
53                break;
54                case "print":
55                        //let's build the whereclause
56                        $whereclause="";
57                        $dataprint="";
58                        switch($_POST["therecords"]){
59                                case "all":
60                                        $dataprint="All Records";
61                                break;
62                                case "savedsearch":
63                                        if($_POST["savedsearches"]!="" and $_POST["savedsearches"]!="NA")       {
64                                                $querystatement="SELECT name,sqlclause FROM usersearches WHERE id=".$_POST["savedsearches"];
65                                                $queryresult=$db->query($querystatement);
66                                                If(!$queryresult) $error = new appError(500,"Could not retrieve saved search. ".$querystatement);
67                                                $therecord=$db->fetchArray($queryresult);
68                                                $whereclause="WHERE ".$therecord["sqlclause"];
69                                                $dataprint=$therecord["name"];
70                                        }
71                                break;
72                                case "selected":
73                                        foreach($tablePrinter->theids as $theid){
74                                                $whereclause.=" or ".$tablePrinter->maintable.".id=".$theid;
75                                        }
76                                        $whereclause="where ".substr($whereclause,3);
77                                        $dataprint="Selected Records";
78                                break;
79                        }                       
80                        $_SESSION["printing"]["whereclause"]=$whereclause;
81                        $_SESSION["printing"]["dataprint"]=$dataprint;
82                       
83                        //next let's do the sort
84                        $sortorder="";
85                        switch($_POST["thesort"]){
86                                case "single":
87                                        $sortorder=" ORDER BY ".$tablePrinter->maintable.".".$_POST["singlefield"]." ".$_POST["order"];
88                                break;
89                                case "savedsort":
90                                        if($_POST["savedsorts"]!="" and $_POST["savedsorts"]!="NA")     {
91                                                $querystatement="SELECT sqlclause FROM usersearches WHERE id=".$_POST["savedsorts"];
92                                                $queryresult=$db->query($querystatement);
93                                                If(!$queryresult) $error = new appError(500,"Could not retrieve saved search. ".$querystatement);
94                                                $therecord=$db->fetchArray($queryresult);
95                                                $sortorder=" ORDER BY ".$therecord["sqlclause"];
96                                        }
97                                break;
98                        }
99                        $_SESSION["printing"]["sortorder"]=$sortorder;
100                       
101                        if(isset($_POST["choosereport"])){
102                                $tablePrinter->openwindows="";
103                                for($i=0;$i<count($_POST["choosereport"]);$i++){
104                                        if($_POST["choosereport"][$i]){
105                                                $querystatement="SELECT reportfile,type from reports where id=".$_POST["choosereport"][$i].";";
106                                                $queryresult=$db->query($querystatement);
107                                                if(!$queryresult) $error = new appError(100,"Could not Retreive Report Information");                           
108                                                $reportrecord=$db->fetchArray($queryresult);   
109                                                $fakeExtForIE="";
110                                                if($reportrecord["type"]=="PDF Report")
111                                                        $fakeExtForIE="&ext=.pdf";
112                                                $dateTimeStamp="&ts=".mktime(); // make the url unique to avoid using browser cache
113                                                //javascript open each report in new window
114                                                $tablePrinter->openwindows.="window.open('".APP_PATH.$reportrecord["reportfile"]."?tid=".urlencode($tablePrinter->tableid).$dateTimeStamp.$fakeExtForIE."','print".$i."');\n";
115                                        }
116                                }
117                        }                       
118                break;
119        }
120}
121
122$pageTitle="Print/Export";
123
124$phpbms->showMenu = false;
125
126$phpbms->cssIncludes[] = "pages/print.css";
127
128$phpbms->jsIncludes[] = "common/javascript/print.js";
129
130$phpbms->topJS[] = $tablePrinter->showJavaScriptArray();
131
132if($tablePrinter->openwindows) $phpbms->bottomJS[] = $tablePrinter->openwindows;
133
134include("header.php");
135?>
136<div >
137<div class="bodyline" id="mainbody">
138        <h1><?php echo $pageTitle ?><a name="top"></a></h1>
139       
140<form action="print.php" method="post" name="print">
141        <input type="hidden" name="backurl" value="<?php echo $_GET["backurl"]?>" />
142
143        <fieldset id="fsReportInformation" >
144                <legend>report information</legend>
145                <?php 
146                        if ($db->numRows($tablePrinter->reports)){
147                                $db->seek($tablePrinter->reports,0); 
148                                $therecord=$db->fetchArray($tablePrinter->reports);
149                        } else {
150                                $therecord["id"]=0;
151                                $therecord["reportfile"]="";
152                                $therecord["name"]="";
153                                $therecord["type"]="";
154                                $therecord["description"]="";
155                        }
156                ?>
157                <p>
158                        name<br />
159                        <input name="reportid" type="hidden" value="<?php echo $therecord["id"] ?>" />
160                        <input name="reportfile" type="hidden" value="<?php echo htmlQuotes($therecord["reportfile"]) ?>" />
161                        <input name="name" type="text" class="uneditable important" id="name" value="<?php echo htmlQuotes($therecord["name"]) ?>" size="32" maxlength="64" readonly="readonly" />             
162                </p>
163               
164                <p>
165                        type<br />
166                        <input name="type" type="text" class="uneditable" id="type" value="<?php echo $therecord["type"] ?>" size="20" maxlength="64" readonly="readonly" />
167                </p>
168                <p>
169                        description<br />
170                        <textarea name="description" cols="45" rows="3" readonly="readonly" id="description" class="uneditable"><?php echo stripcslashes($therecord["description"]) ?></textarea>
171                </p>
172        </fieldset>
173
174        <div id="selectReportsDiv">
175        <fieldset>
176                <legend>select report(s)</legend>
177                <p>available reports<br />
178                        <?php $tablePrinter->displayReportList()?>
179                </p>
180        </fieldset>
181        </div>
182
183        <p><button id="showoptions" class="graphicButtons buttonDown" type="button"><span>more options</span></button></p>
184       
185        <div id="moreoptions">
186                <fieldset>
187                        <legend>data</legend>
188                        <p id="showsavedsearches">
189                                <label for="savedsearches">load saved search...</label><br />
190                                <?php $tablePrinter->showSaved($tablePrinter->savedSearches,"savedsearches");?>
191                        </p>
192
193                        <p>
194                                <label class="important" for="therecords">from</label><br />
195                                <select id="therecords" name="therecords" onchange="showSavedSearches(this);">
196                                        <option value="selected">selected records (<?php echo count($tablePrinter->theids) ?> record<?php if(count($tablePrinter->theids)>1) echo "s"?>)</option>
197                                        <option value="savedsearch">saved search...</option>
198                                        <?php if($_SESSION["userinfo"]["admin"]==1){?><option value="all">all records in table</option><?php }?>
199                                </select>
200                        </p>
201                </fieldset>
202               
203                <fieldset>
204                        <legend>sort</legend>
205                       
206                        <p id="savedsortdiv">
207                                <label for="savedsorts">saved sort...</label><br />
208                                <?php $tablePrinter->showSaved($tablePrinter->savedSorts,"savedsorts");?>
209                        </p>
210                       
211                        <p id="singlesortdiv">
212                                <label for="singlefield">field</label><br />
213                                <?php $tablePrinter->showFieldSort()?>
214                                <select name="order">
215                                        <option value="ASC" selected="selected">Ascending</option>
216                                        <option value="DESC">Descending</option>
217                                </select>                       
218                        </p>
219                        <p class="important">
220                                <label for="thesort">by</label><br />
221                                <select id="thesort" name="thesort" onchange="showSortOptions(this)">
222                                        <option value="default" selected="selected">report default</option>
223                                        <option value="single">single field</option>
224                                        <option value="savedsort">saved sort...</option>
225                                </select>
226                        </p>
227                </fieldset>
228                <fieldset>
229                        <legend>customizng reports</legend>
230                        <p class="notes">
231                        Many reports feature a logo and your company infromation.  This information can be set administratively in the configuration area
232                        </p>
233                        <p class="notes">
234                        Need more reports, or want to cuztomize an existing report to meet your specific needs? <br />
235                        if you are unfamiliar with PHP, or programming phpBMS, you can try visiting the
236                        <a href="http://www.phpbms.org">phpBMS project site</a>, or visit <a href="http://kreotek.com">Kreotek's website</a> for more information.
237                        </p>
238                </fieldset>
239        </div> 
240        <fieldset class="small">
241                <legend>Pop-Up Windows</legend>
242                <p class="notes">
243                        Each report will display in its own window. If you have disabled
244                        pop-ups within your browser's options or are running a third-party pop-up blocker, the report may not show.
245                </p>
246        </fieldset>
247
248        <p id="printFooter">
249                <input name="command" type="submit" class="Buttons" id="printButton" value="print" accesskey="p" title="print (alt+p)" />
250                <input name="command" type="submit" class="Buttons" id="cancel" value="done" accesskey="d" title="done (alt+d)" />       
251        </p>
252   </form>
253</div>
254</div>
255<?php include("footer.php")?>
Note: See TracBrowser for help on using the browser.
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.