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
),
54 //val zero is deprecated and is the facility identifier
55 //val two should be the procedure key, or put another way an id in the billing able
56 //trim due to ugly perl string cast hack
57 $obj= $m->getparam(1);
58 $key = trim($obj->getval());
60 $db = $GLOBALS['adodb']['db'];
62 $sql = "SELECT x.name FROM billing as b LEFT JOIN x12_partners as x on x.id = b.x12_partner_id 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) {
92 $obj= $m->getparam(0);
93 $key = $obj->getval();
95 $sql = "SELECT * FROM facility where billing_location = '1'";
97 $db = $GLOBALS['adodb']['db'];
98 $results = $db->Execute($sql);
101 $err = $db->ErrorMsg();
104 if (!$results->EOF
) {
105 $retval = $results->fields
['street'];
108 // if we generated an error, create an error return response
110 return $this->_handleError($err);
113 // otherwise, we create the right response
114 // with the state name
115 return new xmlrpcresp(new xmlrpcval($retval));
124 $obj= $m->getparam(0);
125 $key = $obj->getval();
127 $sql = "SELECT * FROM facility where billing_location = '1'";
129 $db = $GLOBALS['adodb']['db'];
130 $results = $db->Execute($sql);
133 $err = $db->ErrorMsg();
136 if (!$results->EOF
) {
137 $retval = $results->fields
['city'];
141 // if we generated an error, create an error return response
143 return $this->_handleError($err);
146 // otherwise, we create the right response
147 // with the state name
148 return new xmlrpcresp(new xmlrpcval($retval));
155 $obj= $m->getparam(0);
156 $key = $obj->getval();
158 $sql = "SELECT * FROM facility where billing_location = '1'";
160 $db = $GLOBALS['adodb']['db'];
161 $results = $db->Execute($sql);
164 $err = $db->ErrorMsg();
167 if (!$results->EOF
) {
168 $retval = $results->fields
['state'];
172 // if we generated an error, create an error return response
174 return $this->_handleError($err);
177 // otherwise, we create the right response
178 // with the state name
179 return new xmlrpcresp(new xmlrpcval($retval));
183 function zipcode($m) {
187 $obj= $m->getparam(0);
188 $key = $obj->getval();
190 $sql = "SELECT * FROM facility where billing_location = '1'";
192 $db = $GLOBALS['adodb']['db'];
193 $results = $db->Execute($sql);
196 $err = $db->ErrorMsg();
199 if (!$results->EOF
) {
200 $retval = $results->fields
['postal_code'];
204 // if we generated an error, create an error return response
206 return $this->_handleError($err);
209 // otherwise, we create the right response
210 // with the state name
211 return new xmlrpcresp(new xmlrpcval($retval));
214 function phonecountry($m) {
220 // if we generated an error, create an error return response
222 return $this->_handleError($err);
225 // otherwise, we create the right response
226 // with the state name
227 return new xmlrpcresp(new xmlrpcval($pkey));
231 function phoneextension($m) {
237 // if we generated an error, create an error return response
239 return $this->_handleError($err);
242 // otherwise, we create the right response
243 // with the state name
244 return new xmlrpcresp(new xmlrpcval($pkey));
248 function phonearea($m) {
252 $obj= $m->getparam(0);
253 $key = $obj->getval();
255 $sql = "SELECT * FROM facility where billing_location = '1'";
257 $db = $GLOBALS['adodb']['db'];
258 $results = $db->Execute($sql);
261 $err = $db->ErrorMsg();
264 if (!$results->EOF
) {
265 $retval = $results->fields
['phone'];
269 $phone_parts = array();
270 // preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
271 preg_match("/(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d)/",$retval,$phone_parts);
272 $retval = $phone_parts[1];
274 // if we generated an error, create an error return response
276 return $this->_handleError($err);
279 // otherwise, we create the right response
280 // with the state name
281 return new xmlrpcresp(new xmlrpcval($retval));
284 function phonenumber($m) {
288 $obj= $m->getparam(0);
289 $key = $obj->getval();
291 $sql = "SELECT * FROM facility where billing_location = '1'";
293 $db = $GLOBALS['adodb']['db'];
294 $results = $db->Execute($sql);
297 $err = $db->ErrorMsg();
300 if (!$results->EOF
) {
301 $retval = $results->fields
['phone'];
305 $phone_parts = array();
306 // preg_match("/^\((.*?)\)\s(.*?)\-(.*?)$/",$retval,$phone_parts);
307 preg_match("/(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d)/",$retval,$phone_parts);
308 $retval = $phone_parts[2] . "-" . $phone_parts[3];
310 // if we generated an error, create an error return response
312 return $this->_handleError($err);
315 // otherwise, we create the right response
316 // with the state name
317 return new xmlrpcresp(new xmlrpcval($retval));
324 //val zero is deprecated and is the facility identifier
325 //val two should be the procedure key, or put another way an id in the billing able
326 //trim due to ugly perl string cast hack
327 $obj= $m->getparam(1);
328 $key = trim($obj->getval());
330 $db = $GLOBALS['adodb']['db'];
332 $sql = "SELECT x.id_number FROM billing as b LEFT JOIN x12_partners as x on x.id = b.x12_partner_id where b.id= " .$db->qstr($key) ;
335 $results = $db->Execute($sql);
339 $err = $db->ErrorMsg();
342 if (!$results->EOF
) {
343 $retval = $results->fields
['id_number'];
347 // if we generated an error, create an error return response
349 return $this->_handleError($err);
352 // otherwise, we create the right response
353 // with the state name
354 return new xmlrpcresp(new xmlrpcval($retval));
357 function x12gsreceiverid($m) {
361 //val zero is deprecated and is the facility identifier
362 //val two should be the procedure key, or put another way an id in the billing able
363 //trim due to ugly perl string cast hack
364 $obj= $m->getparam(1);
365 $key = trim($obj->getval());
367 $db = $GLOBALS['adodb']['db'];
369 $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) ;
372 $results = $db->Execute($sql);
376 $err = $db->ErrorMsg();
379 if (!$results->EOF
) {
380 $retval = $results->fields
['x12_receiver_id'];
384 while (strlen($retval) < 15) {
388 // if we generated an error, create an error return response
390 return $this->_handleError($err);
393 // otherwise, we create the right response
394 // with the state name
395 return new xmlrpcresp(new xmlrpcval($retval));
399 function x12gssenderid($m) {
403 //val zero is deprecated and is the facility identifier
404 //val two should be the procedure key, or put another way an id in the billing able
405 //trim due to ugly perl string cast hack
406 $obj= $m->getparam(1);
407 $key = trim($obj->getval());
409 $db = $GLOBALS['adodb']['db'];
411 $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) ;
414 $results = $db->Execute($sql);
418 $err = $db->ErrorMsg();
421 if (!$results->EOF
) {
422 $retval = $results->fields
['x12_sender_id'];
426 while (strlen($retval) < 15) {
429 // if we generated an error, create an error return response
431 return $this->_handleError($err);
434 // otherwise, we create the right response
435 // with the state name
436 return new xmlrpcresp(new xmlrpcval($retval));
441 function x12gsversionstring($m) {
445 //val zero is deprecated and is the facility identifier
446 $obj= $m->getparam(0);
447 $key = $obj->getval();
449 $db = $GLOBALS['adodb']['db'];
451 $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);
454 $results = $db->Execute($sql);
458 $err = $db->ErrorMsg();
461 if (!$results->EOF
) {
462 $retval = $results->fields
['x12_version'];
465 // if we generated an error, create an error return response
467 return $this->_handleError($err);
470 // otherwise, we create the right response
471 // with the state name
472 return new xmlrpcresp(new xmlrpcval($retval));
478 //'FreeB.FBClearingHouse.Name' => \&FreeB_FBClearingHouse_Name,
479 //'FreeB.FBClearingHouse.StreetAddress' => \&FreeB_FBClearingHouse_StreetAddress,
480 //'FreeB.FBClearingHouse.City' => \&FreeB_FBClearingHouse_City,
481 //'FreeB.FBClearingHouse.State' => \&FreeB_FBClearingHouse_State,
482 //'FreeB.FBClearingHouse.Zipcode' => \&FreeB_FBClearingHouse_Zipcode,
483 //'FreeB.FBClearingHouse.PhoneCountry' => \&FreeB_FBClearingHouse_PhoneCountry,
484 //'FreeB.FBClearingHouse.PhoneExtension' => \&FreeB_FBClearingHouse_PhoneExtension,
485 //'FreeB.FBClearingHouse.PhoneArea' => \&FreeB_FBClearingHouse_PhoneArea,
486 //'FreeB.FBClearingHouse.PhoneNumber' => \&FreeB_FBClearingHouse_PhoneNumber,
487 //'FreeB.FBClearingHouse.ETIN' => \&FreeB_FBClearingHouse_ETIN,
488 //'FreeB.FBClearingHouse.X12GSReceiverID' => \&FreeB_FBClearingHouse_X12GSReceiverID,
489 //'FreeB.FBClearingHouse.X12GSSenderID' => \&FreeB_FBClearingHouse_X12GSSenderID,