Space to separate "&&" so that all "&$var" can be made into "$var" later
[openemr.git] / library / classes / Company.class.php
blobf7fa68e8aefc8350d82aaf543ae9d18748c44eae
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 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 company($id = "", $foreign_id = "") {
32 $this->id = $id;
33 $this->name = "";
34 $this->foreign_id = $foreign_id;
35 $this->_table = "companies";
36 $this->line1 = "";
37 $this->line2 = "";
38 $this->city = "";
39 $this->state = "";
40 $this->zip = "";
41 $this->plus_four = "";
42 $this->country = "USA";
43 if ($id != "") {
44 $this->populate();
49 function factory_company($foreign_id = "") {
50 if (empty($foreign_id)) {
51 $foreign_id= "like '%'";
53 else {
54 $foreign_id= " = '" . mysql_real_escape_string(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 = mysql_fetch_array($results);
62 if (!empty($row)) {
63 $a = new Address($row['id']);
66 return $a;
69 function toString($html = false) {
70 $string .= "\n"
71 . "ID: " . $this->id."\n"
72 . "FID: " . $this->foreign_id."\n"
73 .$this->line1 . "\n"
74 .$this->line2 . "\n"
75 .$this->city . ", " . strtoupper($this->state) . " " . $this->zip . "-" . $this->plus_four. "\n"
76 .$this->country. "\n";
78 if ($html) {
79 return nl2br($string);
81 else {
82 return $string;
86 function set_id($id) {
87 $this->id = $id;
89 function get_id() {
90 return $this->id;
92 function set_name($name) {
93 $this->name = $name;
95 function get_name() {
96 return $this->name;
98 function set_foreign_id($fid) {
99 $this->foreign_id = $fid;
101 function get_foreign_id() {
102 return $this->foreign_id;
104 function set_line1($line1) {
105 $this->line1 = $line1;
107 function get_line1() {
108 return $this->line1;
110 function set_line2($line2) {
111 $this->line2 = $line2;
113 function get_line2() {
114 return $this->line2;
116 function set_city($city) {
117 $this->city = $city;
119 function get_city() {
120 return $this->city;
122 function set_state($state) {
123 $this->state = $state;
125 function get_state() {
126 return $this->state;
128 function set_zip($zip) {
129 $this->zip = $zip;
131 function get_zip() {
132 return $this->zip;
134 function set_plus_four($plus_four) {
135 $this->plus_four = $plus_four;
137 function get_plus_four() {
138 return $this->plus_four;
140 function set_country($country) {
141 $this->country = $country;
143 function get_country() {
144 return $this->country;
146 function persist($fid ="") {
147 if (!empty($fid)) {
148 $this->foreign_id = $fid;
150 parent::persist();
153 } // end of Company