mysql 8 fixes (#1639)
[openemr.git] / library / classes / Company.class.php
blob7b3768db91469881a0f5c022ecee24db55c4959b
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 if (empty($foreign_id)) {
51 $foreign_id= "like '%'";
52 } else {
53 $foreign_id= " = '" . add_escape_custom(strval($foreign_id)) . "'";
56 $a = new Address();
57 $sql = "SELECT id FROM " . $a->_table . " WHERE foreign_id " .$foreign_id ;
58 //echo $sql . "<bR />";
59 $results = sqlQ($sql);
60 //echo "sql: $sql";
61 $row = sqlFetchArray($results);
62 if (!empty($row)) {
63 $a = new Address($row['id']);
66 return $a;
69 function toString($html = false)
71 $string .= "\n"
72 . "ID: " . $this->id."\n"
73 . "FID: " . $this->foreign_id."\n"
74 .$this->line1 . "\n"
75 .$this->line2 . "\n"
76 .$this->city . ", " . strtoupper($this->state) . " " . $this->zip . "-" . $this->plus_four. "\n"
77 .$this->country. "\n";
79 if ($html) {
80 return nl2br($string);
81 } else {
82 return $string;
86 function set_id($id)
88 $this->id = $id;
90 function get_id()
92 return $this->id;
94 function set_name($name)
96 $this->name = $name;
98 function get_name()
100 return $this->name;
102 function set_foreign_id($fid)
104 $this->foreign_id = $fid;
106 function get_foreign_id()
108 return $this->foreign_id;
110 function set_line1($line1)
112 $this->line1 = $line1;
114 function get_line1()
116 return $this->line1;
118 function set_line2($line2)
120 $this->line2 = $line2;
122 function get_line2()
124 return $this->line2;
126 function set_city($city)
128 $this->city = $city;
130 function get_city()
132 return $this->city;
134 function set_state($state)
136 $this->state = $state;
138 function get_state()
140 return $this->state;
142 function set_zip($zip)
144 $this->zip = $zip;
146 function get_zip()
148 return $this->zip;
150 function set_plus_four($plus_four)
152 $this->plus_four = $plus_four;
154 function get_plus_four()
156 return $this->plus_four;
158 function set_country($country)
160 $this->country = $country;
162 function get_country()
164 return $this->country;
166 function persist($fid = "")
168 if (!empty($fid)) {
169 $this->foreign_id = $fid;
172 parent::persist();
174 } // end of Company