some portal work
[openemr.git] / library / classes / Company.class.php
blobf1ee43e2180c783c78f9a0a33be61515ae63be10
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 Company extends ORDataObject
17 var $id;
18 var $name;
19 var $foreign_id;
20 var $line1;
21 var $line2;
22 var $city;
23 var $state;
24 var $zip;
25 var $plus_four;
26 var $country;
28 /**
29 * Constructor sets all Company attributes to their default value
31 function __construct($id = "", $foreign_id = "")
33 $this->id = $id;
34 $this->name = "";
35 $this->foreign_id = $foreign_id;
36 $this->_table = "companies";
37 $this->line1 = "";
38 $this->line2 = "";
39 $this->city = "";
40 $this->state = "";
41 $this->zip = "";
42 $this->plus_four = "";
43 $this->country = "USA";
44 if ($id != "") {
45 $this->populate();
48 function factory_company($foreign_id = "")
50 $sqlArray = array();
52 if (empty($foreign_id)) {
53 $foreign_id_sql = " like '%'";
54 } else {
55 $foreign_id_sql = " = ?";
56 $sqlArray[] = strval($foreign_id);
59 $a = new Address();
60 $sql = "SELECT id FROM " . escape_table_name($a->_table) . " WHERE foreign_id " . $foreign_id_sql;
61 //echo $sql . "<bR />";
62 $results = sqlQ($sql, $sqlArray);
63 //echo "sql: $sql";
64 $row = sqlFetchArray($results);
65 if (!empty($row)) {
66 $a = new Address($row['id']);
69 return $a;
72 function toString($html = false)
74 $string .= "\n"
75 . "ID: " . $this->id."\n"
76 . "FID: " . $this->foreign_id."\n"
77 .$this->line1 . "\n"
78 .$this->line2 . "\n"
79 .$this->city . ", " . strtoupper($this->state) . " " . $this->zip . "-" . $this->plus_four. "\n"
80 .$this->country. "\n";
82 if ($html) {
83 return nl2br($string);
84 } else {
85 return $string;
89 function set_id($id)
91 $this->id = $id;
93 function get_id()
95 return $this->id;
97 function set_name($name)
99 $this->name = $name;
101 function get_name()
103 return $this->name;
105 function set_foreign_id($fid)
107 $this->foreign_id = $fid;
109 function get_foreign_id()
111 return $this->foreign_id;
113 function set_line1($line1)
115 $this->line1 = $line1;
117 function get_line1()
119 return $this->line1;
121 function set_line2($line2)
123 $this->line2 = $line2;
125 function get_line2()
127 return $this->line2;
129 function set_city($city)
131 $this->city = $city;
133 function get_city()
135 return $this->city;
137 function set_state($state)
139 $this->state = $state;
141 function get_state()
143 return $this->state;
145 function set_zip($zip)
147 $this->zip = $zip;
149 function get_zip()
151 return $this->zip;
153 function set_plus_four($plus_four)
155 $this->plus_four = $plus_four;
157 function get_plus_four()
159 return $this->plus_four;
161 function set_country($country)
163 $this->country = $country;
165 function get_country()
167 return $this->country;
169 function persist($fid = "")
171 if (!empty($fid)) {
172 $this->foreign_id = $fid;
175 parent::persist();
177 } // end of Company