phpBMS

root/trunk/phpbms/modules/bms/invoices_addresses_ajax.php

Revision 745, 5.4 KB (checked in by brieb, 2 years ago)
  • implemented patch from #398 (small typos and bugs)
  • reinstated debug mode now that release is (almost) done
Line 
1<?php
2/*
3 $Rev: 375 $ | $LastChangedBy: brieb $
4 $LastChangedDate: 2008-01-29 18:01:42 -0700 (Tue, 29 Jan 2008) $
5 +-------------------------------------------------------------------------+
6 | Copyright (c) 2004 - 2010, 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*/
39
40session_cache_limiter('private');
41
42include("../../include/session.php");
43
44class clientAddresses{
45
46        function clientAddresses($db){
47
48                $this->db = $db;
49
50        }//end method - init
51
52
53        function getList($uuid){
54
55                $querystatement = "
56                        SELECT
57                                addresses.*,
58                                addresstorecord.primary,
59                                addresstorecord.defaultshipto
60                        FROM
61                                addresstorecord INNER JOIN addresses ON addresstorecord.addressid = addresses.uuid
62                        WHERE
63                                addresstorecord.tabledefid = 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083'
64                                AND addresstorecord.recordid = '".mysql_real_escape_string($uuid)."'";
65
66                return $this->db->query($querystatement);
67
68        }//end method - get
69
70
71        function displayList($queryresult){
72
73                ?><div class="fauxP">
74                        client addresses<br />
75                        <div id="LAPickDiv">
76                        <?php
77
78                        if($this->db->numRows($queryresult)){
79
80                                while($therecord = $this->db->fetchArray($queryresult)){
81
82                                        $content = "";
83                                        if($therecord["title"])
84                                                $content .= "<strong>".htmlQuotes($therecord["title"])."</strong><br/>";
85
86                                        $content .= htmlQuotes($therecord["address1"]);
87
88                                        if($therecord["address2"])
89                                                $content .= "<br/>".htmlQuotes($therecord["address2"]);
90
91                                        $content .= "<br/>".htmlQuotes($therecord["city"]);
92
93                                        if($therecord["state"])
94                                                $content .= ", ".htmlQuotes($therecord["state"]);
95
96                                        if($therecord["postalcode"])
97                                                $content .= " ".htmlQuotes($therecord["postalcode"]);
98
99                                        if($therecord["country"])
100                                                $content .= "<br/>".htmlQuotes($therecord["country"]);
101
102                                        ?><a href="#" id="LA-<?php echo $therecord["uuid"]?>" class="LAPickAs"><?php echo $content?></a><?php
103
104                                }//endwhile - therecord
105
106                        } else {
107
108                                ?><p><em>no records found</em></p><?php
109
110                        }//endif numrows
111
112                        ?>
113                        </div>
114                </div>
115
116                <p align="right">
117                        <button type="button" class="disabledButtons addressButtons" id="LALoadButton">load</button>
118                        <button type="button" class="Buttons addressButtons" id="LACancelButton">cancel</button>
119                </p>
120                <?php
121
122        }//end method - display
123
124        function showSingle($uuid){
125
126                $querystatement = "
127                        SELECT
128                                *
129                        FROM
130                                addresses
131                        WHERE
132                                uuid ='".mysql_real_escape_string($uuid)."'";
133
134                $therecord = $this->db->fetchArray($this->db->query($querystatement));
135
136                $output = "{";
137
138                foreach($therecord as $key=>$value)
139                        $output .= $key .": '".str_replace("'","\\'",htmlQuotes($value))."' ,";
140
141                $output = substr($output, 0, -1);
142                $output .= "}";
143
144                echo $output;
145
146        }//end method - showSingle
147
148}//end class
149
150
151//processing
152//=========================================================================
153if(isset($_GET["w"]) && isset($_GET["id"])){
154
155        $addresses = new clientAddresses($db);
156
157        switch($_GET["w"]){
158
159                case "s":
160                        //single address record
161                        $addresses->showSingle($_GET["id"]);
162                        break;
163
164                case "l":
165                        //list of addresses for client
166                        $addressResult = $addresses->getList($_GET["id"]);
167
168                        $addresses->displayList($addressResult);
169
170                        break;
171
172        }//endswitch - get w
173
174}//end if
175?>
Note: See TracBrowser for help on using the browser.
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.