2 require_once("DataObjectBase.class.php");
3 require_once("xmlrpc.inc");
5 class ClearingHouse
Extends DataObjectBase
{
7 function ClearingHouse() {
8 $this->_addFunc("name", array( "name" => "FreeB.FBClearingHouse.Name",
9 "sig" => array(XMLRPCSTRING
,XMLRPCINT
,XMLRPCSTRING
),
11 $this->_addFunc("streetaddress", array( "name" => "FreeB.FBClearingHouse.StreetAddress",
12 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
14 $this->_addFunc("city", array( "name" => "FreeB.FBClearingHouse.City",
15 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
17 $this->_addFunc("state", array( "name" => "FreeB.FBClearingHouse.State",
18 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
20 $this->_addFunc("zipcode", array( "name" => "FreeB.FBClearingHouse.Zipcode",
21 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
23 $this->_addFunc("phonecountry", array( "name" => "FreeB.FBClearingHouse.PhoneCountry",
24 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
26 $this->_addFunc("phoneextension", array( "name" => "FreeB.FBClearingHouse.PhoneExtension",
27 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
29 $this->_addFunc("phonearea", array( "name" => "FreeB.FBClearingHouse.PhoneArea",
30 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
32 $this->_addFunc("phonenumber", array( "name" => "FreeB.FBClearingHouse.PhoneNumber",
33 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
35 $this->_addFunc("etin", array( "name" => "FreeB.FBClearingHouse.ETIN",
36 "sig" => array(XMLRPCSTRING
,XMLRPCINT
,XMLRPCSTRING
),
38 $this->_addFunc("x12gsreceiverid", array( "name" => "FreeB.FBClearingHouse.X12GSReceiverID",
39 "sig" => array(XMLRPCSTRING
,XMLRPCINT
,XMLRPCSTRING
),
41 $this->_addFunc("x12gssenderid", array( "name" => "FreeB.FBClearingHouse.X12GSSenderID",
42 "sig" => array(XMLRPCSTRING
,XMLRPCINT
,XMLRPCSTRING
),
44 $this->_addFunc("x12gsversionstring", array( "name" => "FreeB.FBClearingHouse.X12GSVersionString",
45 "sig" => array(XMLRPCSTRING
, XMLRPCINT
),
52 //val zero is deprecated and is the facility identifier
53 //val two should be the procedure key, or put another way an id in the billing able
54 //trim due to ugly perl string cast hack
55 $obj= $m->getparam(1);
56 $key = trim($obj->getval());
58 $db = $GLOBALS['adodb']['db'];
60 $sql = "SELECT x.name FROM billing AS b " .
61 "LEFT JOIN x12_partners AS x ON x.id = b.x12_partner_id " .
62 "where b.id= " .$db->qstr($key) ;
65 $results = $db->Execute($sql);
69 $err = $db->ErrorMsg();
73 $retval = $results->fields
['name'];
77 // if we generated an error, create an error return response
79 return $this->_handleError($err);
82 // otherwise, we create the right response
83 // with the state name
84 return new xmlrpcresp(new xmlrpcval($retval));
88 function streetaddress($m) {
91 $obj= $m->getparam(0);
92 $key = $obj->getval();
94 $sql = "SELECT * FROM facility where billing_location = '1'";
96 $db = $GLOBALS['adodb']['db'];
97 $results = $db->Execute($sql);
100 $err = $db->ErrorMsg();
103 if (!$results->EOF
) {
104 $retval = $results->fields
['street'];
107 // if we generated an error, create an error return response
109 return $this->_handleError($err);
112 // otherwise, we create the right response
113 // with the state name
114 return new xmlrpcresp(new xmlrpcval($retval));
121 $obj= $m->getparam(0);
122 $key = $obj->getval();
124 $sql = "SELECT * FROM facility where billing_location = '1'";
126 $db = $GLOBALS['adodb']['db'];
127 $results = $db->Execute($sql);
130 $err = $db->ErrorMsg();
133 if (!$results->EOF
) {
134 $retval = $results->fields
['city'];
138 // if we generated an error, create an error return response
140 return $this->_handleError($err);
143 // otherwise, we create the right response
144 // with the state name
145 return new xmlrpcresp(new xmlrpcval($retval));
152 $obj= $m->getparam(0);
153 $key = $obj->getval();
155 $sql = "SELECT * FROM facility where billing_location = '1'";
157 $db = $GLOBALS['adodb']['db'];
158 $results = $db->Execute($sql);
161 $err = $db->ErrorMsg();
164 if (!$results->EOF
) {
165 $retval = $results->fields
['state'];
169 // if we generated an error, create an error return response
171 return $this->_handleError($err);
174 // otherwise, we create the right response
175 // with the state name
176 return new xmlrpcresp(new xmlrpcval($retval));
180 function zipcode($m) {
183 $obj= $m->getparam(0);
184 $key = $obj->getval();
186 $sql = "SELECT * FROM facility where billing_location = '1'";
188 $db = $GLOBALS['adodb']['db'];
189 $results = $db->Execute($sql);
192 $err = $db->ErrorMsg();
195 if (!$results->EOF
) {
196 $retval = $results->fields
['postal_code'];
200 // if we generated an error, create an error return response
202 return $this->_handleError($err);
205 // otherwise, we create the right response
206 // with the state name
207 return new xmlrpcresp(new xmlrpcval($retval));
211 function phonecountry($m) {
216 // if we generated an error, create an error return response
218 return $this->_handleError($err);
221 // otherwise, we create the right response
222 // with the state name
223 return new xmlrpcresp(new xmlrpcval($pkey));
227 function phoneextension($m) {
232 // if we generated an error, create an error return response
234 return $this->_handleError($err);
237 // otherwise, we create the right response
238 // with the state name
239 return new xmlrpcresp(new xmlrpcval($pkey));
243 function phonearea($m) {
246 $obj= $m->getparam(0);
247 $key = $obj->getval();
249 $sql = "SELECT * FROM facility where billing_location = '1'";
251 $db = $GLOBALS['adodb']['db'];
252 $results = $db->Execute($sql);
255 $err = $db->ErrorMsg();
258 if (!$results->EOF
) {
259 $retval = $results->fields
['phone'];
263 $phone_parts = array();
264 // preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
265 preg_match("/(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d)/",$retval,$phone_parts);
266 $retval = $phone_parts[1];
268 // if we generated an error, create an error return response
270 return $this->_handleError($err);
273 // otherwise, we create the right response
274 // with the state name
275 return new xmlrpcresp(new xmlrpcval($retval));
279 function phonenumber($m) {
282 $obj= $m->getparam(0);
283 $key = $obj->getval();
285 $sql = "SELECT * FROM facility where billing_location = '1'";
287 $db = $GLOBALS['adodb']['db'];
288 $results = $db->Execute($sql);
291 $err = $db->ErrorMsg();
294 if (!$results->EOF
) {
295 $retval = $results->fields
['phone'];
299 $phone_parts = array();
300 // preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
301 preg_match("/(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d)/",$retval,$phone_parts);
302 $retval = $phone_parts[2] . "-" . $phone_parts[3];
304 // if we generated an error, create an error return response
306 return $this->_handleError($err);
309 // otherwise, we create the right response
310 // with the state name
311 return new xmlrpcresp(new xmlrpcval($retval));
318 //val zero is deprecated and is the facility identifier
319 //val two should be the procedure key, or put another way an id in the billing able
320 //trim due to ugly perl string cast hack
321 $obj= $m->getparam(1);
322 $key = trim($obj->getval());
324 $db = $GLOBALS['adodb']['db'];
326 $sql = "SELECT x.id_number FROM billing AS b " .
327 "LEFT JOIN x12_partners AS x ON x.id = b.x12_partner_id " .
328 "WHERE b.id = " . $db->qstr($key) ;
331 $results = $db->Execute($sql);
335 $err = $db->ErrorMsg();
338 if (!$results->EOF
) {
339 $retval = $results->fields
['id_number'];
343 // if we generated an error, create an error return response
345 return $this->_handleError($err);
348 // otherwise, we create the right response
349 // with the state name
350 return new xmlrpcresp(new xmlrpcval($retval));
354 function x12gsreceiverid($m) {
357 //val zero is deprecated and is the facility identifier
358 //val two should be the procedure key, or put another way an id in the billing able
359 //trim due to ugly perl string cast hack
360 $obj= $m->getparam(1);
361 $key = trim($obj->getval());
363 $db = $GLOBALS['adodb']['db'];
365 $sql = "SELECT x.x12_receiver_id FROM billing as b LEFT JOIN x12_partners as x on x.id = b.x12_partner_id where b.id= " .$db->qstr($key) ;
368 $results = $db->Execute($sql);
372 $err = $db->ErrorMsg();
375 if (!$results->EOF
) {
376 $retval = $results->fields
['x12_receiver_id'];
380 while (strlen($retval) < 15) {
384 // if we generated an error, create an error return response
386 return $this->_handleError($err);
389 // otherwise, we create the right response
390 // with the state name
391 return new xmlrpcresp(new xmlrpcval($retval));
395 function x12gssenderid($m) {
398 //val zero is deprecated and is the facility identifier
399 //val two should be the procedure key, or put another way an id in the billing able
400 //trim due to ugly perl string cast hack
401 $obj= $m->getparam(1);
402 $key = trim($obj->getval());
404 $db = $GLOBALS['adodb']['db'];
406 $sql = "SELECT x.x12_sender_id FROM billing as b LEFT JOIN x12_partners as x on x.id = b.x12_partner_id where b.id= " .$db->qstr($key) ;
409 $results = $db->Execute($sql);
413 $err = $db->ErrorMsg();
416 if (!$results->EOF
) {
417 $retval = $results->fields
['x12_sender_id'];
421 while (strlen($retval) < 15) {
424 // if we generated an error, create an error return response
426 return $this->_handleError($err);
429 // otherwise, we create the right response
430 // with the state name
431 return new xmlrpcresp(new xmlrpcval($retval));
435 function x12gsversionstring($m) {
438 //val zero is deprecated and is the facility identifier
439 $obj= $m->getparam(0);
440 $key = $obj->getval();
442 $db = $GLOBALS['adodb']['db'];
444 $sql = "SELECT x.x12_version FROM billing AS b LEFT JOIN x12_partners as x ON x.id = b.x12_partner_id WHERE b.id= ".$db->qstr($key);
447 $results = $db->Execute($sql);
451 $err = $db->ErrorMsg();
454 if (!$results->EOF
) {
455 $retval = $results->fields
['x12_version'];
458 // if we generated an error, create an error return response
460 return $this->_handleError($err);
463 // otherwise, we create the right response
464 // with the state name
465 return new xmlrpcresp(new xmlrpcval($retval));
472 //'FreeB.FBClearingHouse.Name' => \&FreeB_FBClearingHouse_Name,
473 //'FreeB.FBClearingHouse.StreetAddress' => \&FreeB_FBClearingHouse_StreetAddress,
474 //'FreeB.FBClearingHouse.City' => \&FreeB_FBClearingHouse_City,
475 //'FreeB.FBClearingHouse.State' => \&FreeB_FBClearingHouse_State,
476 //'FreeB.FBClearingHouse.Zipcode' => \&FreeB_FBClearingHouse_Zipcode,
477 //'FreeB.FBClearingHouse.PhoneCountry' => \&FreeB_FBClearingHouse_PhoneCountry,
478 //'FreeB.FBClearingHouse.PhoneExtension' => \&FreeB_FBClearingHouse_PhoneExtension,
479 //'FreeB.FBClearingHouse.PhoneArea' => \&FreeB_FBClearingHouse_PhoneArea,
480 //'FreeB.FBClearingHouse.PhoneNumber' => \&FreeB_FBClearingHouse_PhoneNumber,
481 //'FreeB.FBClearingHouse.ETIN' => \&FreeB_FBClearingHouse_ETIN,
482 //'FreeB.FBClearingHouse.X12GSReceiverID' => \&FreeB_FBClearingHouse_X12GSReceiverID,
483 //'FreeB.FBClearingHouse.X12GSSenderID' => \&FreeB_FBClearingHouse_X12GSSenderID,