NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/Chameleon/trunk/Chameleon/ExtractSR/ExtractSR.phtml

Revision 13 (checked in by jcleary, 17 years ago)

Latest Chameleon code checkout from previous repository

Line 
1 <?php
2 /**
3  * @project     WIX
4  * @revision    $Id: ExtractSR.phtml,v 1.5 2004/12/07 13:26:27 pspencer Exp $
5  * @purpose     This the main user interface page for the extract SR data
6  *              widget.
7  * @author      Paul Spencer (pspencer@dmsolutions.ca)
8  * @copyright
9  * <b>Copyright (c) 2003, DM Solutions Group Inc.</b>
10  * Permission is hereby granted, free of charge, to any person obtaining a
11  * copy of this software and associated documentation files (the "Software"),
12  * to deal in the Software without restriction, including without limitation
13  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  * and/or sell copies of the Software, and to permit persons to whom the
15  * Software is furnished to do so, subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be included
18  * in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
23  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  * DEALINGS IN THE SOFTWARE.
27  **/
28
29 //set the language resource file
30 $GLOBALS["szLanguageResource"] = str_replace("\\","/",dirname(__FILE__))."/ExtractSR.dbf";
31 include( "../session.inc.php" );
32 include( "../CWC2ButtonCache.php" );
33
34 $szDLFilename = (isset($_GET['txtDLFilename']))? $_GET['txtDLFilename'] : 'data.csv';
35 if (isset($_GET['srname']))
36 {
37     $szSessionKey = 'EXTRACTSR_DATA_'.$_GET['srname'];
38     if (isset($_SESSION[$szSessionKey]) && count($_SESSION[$szSessionKey]) > 0)
39     {
40         $aData = $_SESSION[$szSessionKey];
41         $szData = "";
42         $szSep = "";
43         foreach($aData[0] as $key => $data)
44         {
45             $szData .= $szSep.$key;
46             $szSep = ",";
47         }
48         $szData .= "\n";
49         foreach($aData as $row)
50         {
51             $szSep = "";
52             foreach($row as $key=>$data)
53             {
54                 $szData .= $szSep.$data;
55                 $szSep = ",";
56             }
57             $szData .= "\n";
58         }
59         $f = $_SESSION['gszTmpImgPath']."/".$szSessionKey.'.csv';
60         $h = fopen( $f, "w" );
61         fwrite( $h, $szData );
62         fclose( $h );
63     }   
64 }
65
66 // force download if requested
67 if ( isset($_GET['txtExtract']) && $_GET['txtExtract'] == '1')
68 {
69     //print_r($_SESSION);
70     $_SESSION['DOWNLOADFILE'] = $_SESSION['gszTmpWebPath']."/".$szSessionKey.".csv";
71     if (stristr($_SESSION['DOWNLOADFILE'], 'http://') == false )
72         $_SESSION['DOWNLOADFILE'] = 'http://'.$_SERVER['HTTP_HOST'].'/'.$_SESSION['DOWNLOADFILE'];
73     $_SESSION['DOWNLOADFILE_SAVEAS'] = $szDLFilename;
74     session_write_close();
75     header("Location: ../download.phtml?".SID );
76 }
77 ?>
78 <html>
79 <head>
80 <title><?php echo $oMLT->get("0", "Extract Data") ?></title>
81 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
82 <link rel="stylesheet" type="text/css" href=" <?php echo $szCSSFile ?> ">
83 <style type="text/css">
84 <!-- .reset
85 /* Defines the style of text labels.
86    - Basic useage sets the size, colour and font of any labels of input
87        elements. */
88 {
89     font-family: Arial, Helvetica, sans-serif;
90     font-size: 8px;
91     color: #ff0000;
92 } -->
93 </style>
94 <script language="JavaScript" src="<?php echo $_SESSION['gszCoreWebPath']; ?>/widgets/js/cwc_dhtml.js" type="text/javascript"></script>
95 <script language="JavaScript" src="<?php echo $_SESSION['gszCoreWebPath']; ?>/widgets/js/cwc_button.js" type="text/javascript"></script>
96 <script language="javascript" type="text/javascript">
97
98 /**
99  * doneLoading()
100  *
101  * Postcondition:  This function executes after the page has loaded.
102  *
103  * @return void.
104  **/
105 function doneLoading()
106 {
107     // give the window focus
108     window.focus();
109
110     // return
111     return;
112 }
113
114 /**
115  * execute()
116  *
117  * Postcondition:  This function submits the page to perform the extraction.
118  *
119  * @return void.
120  **/
121 function execute()
122 {
123     // set the flag to execute data extraction
124     document.forms[0].txtExtract.value = 1;
125
126     // submit the page
127     document.forms[0].submit();
128
129     // return
130     return;
131 }
132
133 function clearStatus()
134 {
135     // reset the status
136     document.forms[0].txtStatus.value="";
137 }
138
139 function checkFileName()
140 {
141     // check file name
142     szFileName = document.forms[0].txtDLFilename.value;
143     nPos = szFileName.indexOf( "'" );
144     if ( nPos >= 0 )
145     {
146         // remove the decimal and anything after
147         document.forms[0].txtDLFilename.value = szFileName.substr( 0, nPos );
148
149         // default if nothing left
150         if ( nPos == 0 )
151             document.forms[0].txtDLFilename.value = "";
152
153         // return
154         return true;
155     }
156     nPos = szFileName.indexOf( "\"" );
157     if ( nPos >= 0 )
158     {
159         // remove the decimal and anything after
160         document.forms[0].txtDLFilename.value = szFileName.substr( 0, nPos );
161
162         // default if nothing left
163         if ( nPos == 0 )
164             document.forms[0].txtDLFilename.value = "";
165
166         // return
167         return true;
168     }
169    
170     nPos = szFileName.indexOf( "\\" );
171     if ( nPos >= 0 )
172     {
173         // remove the decimal and anything after
174         document.forms[0].txtDLFilename.value = szFileName.substr( 0, nPos );
175
176         // default if nothing left
177         if ( nPos == 0 )
178             document.forms[0].txtDLFilename.value = "";
179
180         // return
181         return true;
182     }
183 }
184
185 function CloseWindow()
186 {
187     window.close();
188 }
189 </script>
190 </head>
191 <body class="page" onload="javascript:doneLoading()">
192 <form>
193 <table border="0" cellpadding="1" cellspacing="10">
194   <tr>
195     <td class="layoutTable">
196       <table class="titleArea" width="100%" border="0" cellpadding="4" cellspacing="0">
197         <tr>
198           <td><span class="title"><?php echo $oMLT->get("0", "Extract Data") ?></span></td>
199         </tr>
200       </table>
201       <table class="contentArea" width="100%" border="0" cellpadding="4" cellspacing="0">
202         <tr>
203           <td align="center"><p class="helpArea"><?php echo trim($oMLT->get("1", "Click 'extract' to download your data")) ?></p></td>
204         </tr>
205       </table>
206       <table class="contentArea" width="100%" border="0" cellpadding="4" cellspacing="0">
207         <tr>
208           <td align="left" nowrap><span class="label"><?php echo $oMLT->get("2", 'Output file name') ?>:</span></td>
209           <td>
210             <input type="text" name="txtDLFilename" value="<?php echo $szDLFilename; ?>" size="15" onkeyup="javascript:checkFileName()"></td>
211           </td>
212         </tr>
213         <tr>
214           <td align="right" colspan="2" width="350">
215             <input type="button" name="butExtract" value="<?php echo $oMLT->get("3", "Extract") ?>" onmouseup="javascript:execute()"></td>
216         </tr>
217       </table>
218     </td>
219   </tr>
220   <tr>
221     <td align="right">
222       <?php echo makeButton( 'CloseWindow', '', 'ExtractSR', "icons/icon_cancel.png", $oCommonMLT->get("Close", "Close"), $oCommonMLT->get("CloseTip", "Close Dialog"), array( 'width' => 75) ); ?>
223     </td>
224   </tr>
225 </table>
226 <!--  HIDDEN VARIABLES -->
227 <input type="hidden" name="srname" value="<?php echo $_GET['srname']?>">
228 <input type="hidden" name="txtExtract" value="">
229 <input type="hidden" name="sid" value="<?php echo session_id() ?>">
230 </form>
231 </body>
232 </html>
Note: See TracBrowser for help on using the browser.