Syntax fixes - static methods, call by reference and undefined variables
[openemr.git] / library / classes / Address.class.php
blob4f3851ddf7cfa9e7e96646d79e8a5adec9a3cbb3
1 <?php
2 /************************************************************************
3 address.php - Copyright duhlman
5 /usr/share/apps/umbrello/headings/heading.php
7 This file was generated on %date% at %time%
8 The original location of this file is /home/duhlman/uml-generated-code/prescription.php
9 **************************************************************************/
11 require_once("ORDataObject.class.php");
12 /**
13 * class Address
16 class Address extends ORDataObject{
17 var $id;
18 var $foreign_id;
19 var $line1;
20 var $line2;
21 var $city;
22 var $state;
23 var $zip;
24 var $plus_four;
25 var $country;
27 /**
28 * Constructor sets all Address attributes to their default value
30 function Address($id = "", $foreign_id = "") {
31 $this->id = $id;
32 $this->foreign_id = $foreign_id;
33 $this->_table = "addresses";
34 $this->line1 = "";
35 $this->line2 = "";
36 $this->city = "";
37 $this->state = "";
38 $this->zip = "";
39 $this->plus_four = "";
40 $this->country = "USA";
41 if ($id != "") {
42 $this->populate();
47 static function factory_address($foreign_id = "") {
48 if (empty($foreign_id)) {
49 $foreign_id= "like '%'";
51 else {
52 $foreign_id= " = '" . mysql_real_escape_string(strval($foreign_id)) . "'";
54 $a = new Address();
55 $sql = "SELECT id FROM " . $a->_table . " WHERE foreign_id " .$foreign_id ;
56 //echo $sql . "<bR />";
57 $results = sqlQ($sql);
58 //echo "sql: $sql";
59 $row = mysql_fetch_array($results);
60 if (!empty($row)) {
61 $a = new Address($row['id']);
64 return $a;
67 function toString($html = false) {
68 $string .= "\n"
69 . "ID: " . $this->id."\n"
70 . "FID: " . $this->foreign_id."\n"
71 .$this->line1 . "\n"
72 .$this->line2 . "\n"
73 .$this->city . ", " . strtoupper($this->state) . " " . $this->zip . "-" . $this->plus_four. "\n"
74 .$this->country. "\n";
76 if ($html) {
77 return nl2br($string);
79 else {
80 return $string;
84 function set_id($id) {
85 $this->id = $id;
87 function get_id() {
88 return $this->id;
90 function set_foreign_id($fid) {
91 $this->foreign_id = $fid;
93 function get_foreign_id() {
94 return $this->foreign_id;
96 function set_line1($line1) {
97 $this->line1 = $line1;
99 function get_line1() {
100 return $this->line1;
102 function set_line2($line2) {
103 $this->line2 = $line2;
105 function get_line2() {
106 return $this->line2;
108 function get_lines_display() {
109 $string .= $this->get_line1();
110 $string .= " " . $this->get_line2();
111 return $string;
113 function set_city($city) {
114 $this->city = $city;
116 function get_city() {
117 return $this->city;
119 function set_state($state) {
120 $this->state = strtoupper($state);
122 function get_state() {
123 return $this->state;
125 function set_zip($zip) {
126 $this->zip = $zip;
128 function get_zip() {
129 return $this->zip;
131 function set_plus_four($plus_four) {
132 $this->plus_four = $plus_four;
134 function get_plus_four() {
135 return $this->plus_four;
137 function set_country($country) {
138 $this->country = $country;
140 function get_country() {
141 return $this->country;
143 function persist($fid ="") {
144 if (!empty($fid)) {
145 $this->foreign_id = $fid;
147 parent::persist();
150 } // end of Address
152 $a = new Address("0");
154 echo $a->toString(true);*/