docker dev update
[openemr.git] / library / classes / Address.class.php
blob6ad1564f8bb932aa79c52492e2bbb2cd7d63f846
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 /**
12 * class Address
15 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 __construct($id = "", $foreign_id = "")
32 $this->id = $id;
33 $this->foreign_id = $foreign_id;
34 $this->_table = "addresses";
35 $this->line1 = "";
36 $this->line2 = "";
37 $this->city = "";
38 $this->state = "";
39 $this->zip = "";
40 $this->plus_four = "";
41 $this->country = "USA";
42 if ($id != "") {
43 $this->populate();
46 static function factory_address($foreign_id = "")
48 if (empty($foreign_id)) {
49 $foreign_id= "like '%'";
50 } else {
51 $foreign_id= " = '" . add_escape_custom(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 = sqlFetchArray($results);
60 if (!empty($row)) {
61 $a = new Address($row['id']);
64 return $a;
67 function toString($html = false)
69 $string .= "\n"
70 . "ID: " . $this->id."\n"
71 . "FID: " . $this->foreign_id."\n"
72 .$this->line1 . "\n"
73 .$this->line2 . "\n"
74 .$this->city . ", " . strtoupper($this->state) . " " . $this->zip . "-" . $this->plus_four. "\n"
75 .$this->country. "\n";
77 if ($html) {
78 return nl2br($string);
79 } else {
80 return $string;
84 function set_id($id)
86 $this->id = $id;
88 function get_id()
90 return $this->id;
92 function set_foreign_id($fid)
94 $this->foreign_id = $fid;
96 function get_foreign_id()
98 return $this->foreign_id;
100 function set_line1($line1)
102 $this->line1 = $line1;
104 function get_line1()
106 return $this->line1;
108 function set_line2($line2)
110 $this->line2 = $line2;
112 function get_line2()
114 return $this->line2;
116 function get_lines_display()
118 $string .= $this->get_line1();
119 $string .= " " . $this->get_line2();
120 return $string;
122 function set_city($city)
124 $this->city = $city;
126 function get_city()
128 return $this->city;
130 function set_state($state)
132 $this->state = strtoupper($state);
134 function get_state()
136 return $this->state;
138 function set_zip($zip)
140 $this->zip = $zip;
142 function get_zip()
144 return $this->zip;
146 function set_plus_four($plus_four)
148 $this->plus_four = $plus_four;
150 function get_plus_four()
152 return $this->plus_four;
154 function set_country($country)
156 $this->country = $country;
158 function get_country()
160 return $this->country;
162 function persist($fid = "")
164 if (!empty($fid)) {
165 $this->foreign_id = $fid;
168 parent::persist();
170 } // end of Address
172 $a = new Address("0");
174 echo $a->toString(true);*/