2 require_once(dirname(__FILE__
) . "/../patient.inc");
3 include_once (dirname(__FILE__
) . "/../sqlconf.php");
4 include_once (dirname(__FILE__
) . "/../../includes/config.php");
6 class WSProvider
extends WSWrapper
{
12 function WSProvider($user_id) {
13 if (!is_numeric($user_id))
16 parent
::WSWrapper(null,false);
18 $this->user_id
= $user_id;
19 $this->_db
= $GLOBALS['adodb']['db'];
21 if (!$this->_config
['enabled']) return;
23 if ($this->load_info()) {
24 $function['ezybiz.add_salesman'] = array(new xmlrpcval($this->data
,"struct"));
25 $this->send($function);
27 // if the remote user was added make an entry in the local mapping table to that updates can be made correctly
28 if (is_numeric($this->value
)) {
29 $sql = "REPLACE INTO integration_mapping set id = '" . $this->_db
->GenID("sequences") . "', foreign_id ='" . $this->value
. "', foreign_table ='salesman', local_id = '" . $this->user_id
. "', local_table = 'users' ";
30 $this->_db
->Execute($sql) or die ("error: " . $this->_db
->ErrorMsg());
35 function load_info() {
36 $user_info = getProviderInfo($this->user_id
);
38 if (count($user_info)) {
39 //returns array of arrays with 1 array
40 $user_info = $user_info[0];
42 $sql = "SELECT foreign_id,foreign_table FROM integration_mapping where local_table = 'users' and local_id = '" . $this->user_id
. "'";
43 $result = $this->_db
->Execute($sql);
44 if ($result && !$result->EOF
) {
45 $user_info['foreign_update'] = true;
46 $user_info['foreign_id'] = $result->fields
['foreign_id'];
47 $user_info['foreign_table'] = $result->fields
['foreign_table'];
50 $this->data
= array();
54 $this->data
= $user_info;