Code type module improvements:
[openemr.git] / library / freeb / BillingContact.class.php
bloba6be9e6c529a8a92655ce47c033b627b44a4bac2
1 <?php
2 require_once("DataObjectBase.class.php");
3 require_once("xmlrpc.inc");
5 class BillingContact Extends DataObjectBase {
7 function BillingContact() {
8 $this->_addFunc("firstname", array( "name" => "FreeB.FBBillingContact.FirstName",
9 "sig" => array(XMLRPCSTRING,XMLRPCINT),
10 "doc" => ""));
11 $this->_addFunc("middlename", array( "name" => "FreeB.FBBillingContact.MiddleName",
12 "sig" => array(XMLRPCSTRING,XMLRPCINT),
13 "doc" => ""));
14 $this->_addFunc("lastname", array( "name" => "FreeB.FBBillingContact.LastName",
15 "sig" => array(XMLRPCSTRING,XMLRPCINT),
16 "doc" => ""));
17 $this->_addFunc("streetaddress", array( "name" => "FreeB.FBBillingContact.StreetAddress",
18 "sig" => array(XMLRPCSTRING,XMLRPCINT),
19 "doc" => ""));
20 $this->_addFunc("city", array( "name" => "FreeB.FBBillingContact.City",
21 "sig" => array(XMLRPCSTRING,XMLRPCINT),
22 "doc" => ""));
23 $this->_addFunc("state", array( "name" => "FreeB.FBBillingContact.State",
24 "sig" => array(XMLRPCSTRING,XMLRPCINT),
25 "doc" => ""));
26 $this->_addFunc("zipcode", array( "name" => "FreeB.FBBillingContact.Zipcode",
27 "sig" => array(XMLRPCSTRING,XMLRPCINT),
28 "doc" => ""));
29 $this->_addFunc("phonecountry", array( "name" => "FreeB.FBBillingContact.PhoneCountry",
30 "sig" => array(XMLRPCSTRING,XMLRPCINT),
31 "doc" => ""));
32 $this->_addFunc("phoneextension", array( "name" => "FreeB.FBBillingContact.PhoneExtension",
33 "sig" => array(XMLRPCSTRING,XMLRPCINT),
34 "doc" => ""));
35 $this->_addFunc("phonearea", array( "name" => "FreeB.FBBillingContact.PhoneArea",
36 "sig" => array(XMLRPCSTRING,XMLRPCINT),
37 "doc" => ""));
38 $this->_addFunc("phonenumber", array( "name" => "FreeB.FBBillingContact.PhoneNumber",
39 "sig" => array(XMLRPCSTRING,XMLRPCINT),
40 "doc" => ""));
45 function firstname($m) {
47 $err="";
49 $obj= $m->getparam(0);
50 $key = $obj->getval();
52 $sql = "SELECT * FROM facility where billing_location = '1'";
53 //echo $sql;
54 $db = $GLOBALS['adodb']['db'];
55 $results = $db->Execute($sql);
57 if (!$results) {
58 $err = $db->ErrorMsg();
60 else {
61 if (!$results->EOF) {
62 $retval = $results->fields['attn'];
66 // if we generated an error, create an error return response
67 if ($err) {
68 return $this->_handleError($err);
70 else {
71 // otherwise, we create the right response
72 // with the state name
73 return new xmlrpcresp(new xmlrpcval($retval));
77 function middlename($m) {
79 $err="";
81 //unimplemented by OpenEMR
82 $pkey = "";
84 // if we generated an error, create an error return response
85 if ($err) {
86 return $this->_handleError($err);
88 else {
89 // otherwise, we create the right response
90 // with the state name
91 return new xmlrpcresp(new xmlrpcval($pkey));
95 function lastname($m) {
97 $err="";
99 //unimplemented by OpenEMR
100 $pkey = "";
102 // if we generated an error, create an error return response
103 if ($err) {
104 return $this->_handleError($err);
106 else {
107 // otherwise, we create the right response
108 // with the state name
109 return new xmlrpcresp(new xmlrpcval($pkey));
113 function streetaddress($m) {
115 $err="";
117 //unimplemented by OpenEMR
118 $pkey = "";
120 // if we generated an error, create an error return response
121 if ($err) {
122 return $this->_handleError($err);
124 else {
125 // otherwise, we create the right response
126 // with the state name
127 return new xmlrpcresp(new xmlrpcval($pkey));
132 function city($m) {
134 $err="";
136 //unimplemented by OpenEMR
137 $pkey = "";
139 // if we generated an error, create an error return response
140 if ($err) {
141 return $this->_handleError($err);
143 else {
144 // otherwise, we create the right response
145 // with the state name
146 return new xmlrpcresp(new xmlrpcval($pkey));
150 function state($m) {
152 $err="";
154 //unimplemented by OpenEMR
155 $pkey = "";
157 // if we generated an error, create an error return response
158 if ($err) {
159 return $this->_handleError($err);
161 else {
162 // otherwise, we create the right response
163 // with the state name
164 return new xmlrpcresp(new xmlrpcval($pkey));
168 function zipcode($m) {
170 $err="";
172 //unimplemented by OpenEMR
173 $pkey = "";
175 // if we generated an error, create an error return response
176 if ($err) {
177 return $this->_handleError($err);
179 else {
180 // otherwise, we create the right response
181 // with the state name
182 return new xmlrpcresp(new xmlrpcval($pkey));
186 function phonecountry($m) {
188 $err="";
190 //unimplemented by OpenEMR
191 $pkey = "1";
193 // if we generated an error, create an error return response
194 if ($err) {
195 return $this->_handleError($err);
197 else {
198 // otherwise, we create the right response
199 // with the state name
200 return new xmlrpcresp(new xmlrpcval($pkey));
204 function phoneextension($m) {
206 $err="";
209 //unimplemented by OpenEMR
210 $pkey = "";
212 // if we generated an error, create an error return response
213 if ($err) {
214 return $this->_handleError($err);
216 else {
217 // otherwise, we create the right response
218 // with the state name
219 return new xmlrpcresp(new xmlrpcval($pkey));
223 function phonearea($m) {
225 $err="";
227 $obj= $m->getparam(0);
228 $key = $obj->getval();
230 $sql = "SELECT * FROM facility where billing_location = '1'";
231 //echo $sql;
232 $db = $GLOBALS['adodb']['db'];
233 $results = $db->Execute($sql);
235 if (!$results) {
236 $err = $db->ErrorMsg();
238 else {
239 if (!$results->EOF) {
240 $retval = $results->fields['phone'];
244 $phone_parts = array();
245 // preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
246 preg_match("/(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d)/",$retval,$phone_parts);
247 $retval = $phone_parts[1];
249 // if we generated an error, create an error return response
250 if ($err) {
251 return $this->_handleError($err);
253 else {
254 // otherwise, we create the right response
255 // with the state name
256 return new xmlrpcresp(new xmlrpcval($retval));
260 function phonenumber($m) {
262 $err="";
264 $obj= $m->getparam(0);
265 $key = $obj->getval();
267 $sql = "SELECT * FROM facility where billing_location = '1'";
268 //echo $sql;
269 $db = $GLOBALS['adodb']['db'];
270 $results = $db->Execute($sql);
272 if (!$results) {
273 $err = $db->ErrorMsg();
275 else {
276 if (!$results->EOF) {
277 $retval = $results->fields['phone'];
281 $phone_parts = array();
282 // preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
283 preg_match("/(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d)/",$retval,$phone_parts);
284 $retval = $phone_parts[2] . "-" . $phone_parts[3];
286 // if we generated an error, create an error return response
287 if ($err) {
288 return $this->_handleError($err);
290 else {
291 // otherwise, we create the right response
292 // with the state name
293 return new xmlrpcresp(new xmlrpcval($retval));
298 //'FreeB.FBBillingContact.FirstName' => \&FreeB_FBBillingContact_FirstName,
299 //'FreeB.FBBillingContact.MiddleName' => \&FreeB_FBBillingContact_MiddleName,
300 //'FreeB.FBBillingContact.LastName' => \&FreeB_FBBillingContact_LastName,
301 //'FreeB.FBBillingContact.StreetAddress' => \&FreeB_FBBillingContact_StreetAddress,
302 //'FreeB.FBBillingContact.City' => \&FreeB_FBBillingContact_City,
303 //'FreeB.FBBillingContact.State' => \&FreeB_FBBillingContact_State,
304 //'FreeB.FBBillingContact.Zipcode' => \&FreeB_FBBillingContact_Zipcode,
305 //'FreeB.FBBillingContact.PhoneCountry' => \&FreeB_FBBillingContact_PhoneCountry,
306 //'FreeB.FBBillingContact.PhoneExtension' => \&FreeB_FBBillingContact_PhoneExtension,
307 //'FreeB.FBBillingContact.PhoneArea' => \&FreeB_FBBillingContact_PhoneArea,
308 //'FreeB.FBBillingContact.PhoneNumber' => \&FreeB_FBBillingContact_PhoneNumber,