Interim autoloaded library/classes via composer classmap, take 4. (#422)
[openemr.git] / library / classes / Company.class.php
blob45de34aebd4881e98057aa26199fd667cdddb630
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{
16 var $id;
17 var $name;
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 Company attributes to their default value
30 function __construct($id = "", $foreign_id = "") {
31 $this->id = $id;
32 $this->name = "";
33 $this->foreign_id = $foreign_id;
34 $this->_table = "companies";
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();
48 function factory_company($foreign_id = "") {
49 if (empty($foreign_id)) {
50 $foreign_id= "like '%'";
52 else {
53 $foreign_id= " = '" . add_escape_custom(strval($foreign_id)) . "'";
55 $a = new Address();
56 $sql = "SELECT id FROM " . $a->_table . " WHERE foreign_id " .$foreign_id ;
57 //echo $sql . "<bR />";
58 $results = sqlQ($sql);
59 //echo "sql: $sql";
60 $row = sqlFetchArray($results);
61 if (!empty($row)) {
62 $a = new Address($row['id']);
65 return $a;
68 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);
80 else {
81 return $string;
85 function set_id($id) {
86 $this->id = $id;
88 function get_id() {
89 return $this->id;
91 function set_name($name) {
92 $this->name = $name;
94 function get_name() {
95 return $this->name;
97 function set_foreign_id($fid) {
98 $this->foreign_id = $fid;
100 function get_foreign_id() {
101 return $this->foreign_id;
103 function set_line1($line1) {
104 $this->line1 = $line1;
106 function get_line1() {
107 return $this->line1;
109 function set_line2($line2) {
110 $this->line2 = $line2;
112 function get_line2() {
113 return $this->line2;
115 function set_city($city) {
116 $this->city = $city;
118 function get_city() {
119 return $this->city;
121 function set_state($state) {
122 $this->state = $state;
124 function get_state() {
125 return $this->state;
127 function set_zip($zip) {
128 $this->zip = $zip;
130 function get_zip() {
131 return $this->zip;
133 function set_plus_four($plus_four) {
134 $this->plus_four = $plus_four;
136 function get_plus_four() {
137 return $this->plus_four;
139 function set_country($country) {
140 $this->country = $country;
142 function get_country() {
143 return $this->country;
145 function persist($fid ="") {
146 if (!empty($fid)) {
147 $this->foreign_id = $fid;
149 parent::persist();
152 } // end of Company