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;
22 if ($this->_config
['enabled'] === 2) return;
24 if ($this->load_info()) {
25 $function['ezybiz.add_salesman'] = array(new xmlrpcval($this->data
,"struct"));
26 $this->send($function);
28 // if the remote user was added make an entry in the local mapping table to that updates can be made correctly
29 if (is_numeric($this->value
)) {
30 $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' ";
31 $this->_db
->Execute($sql) or die ("error: " . $this->_db
->ErrorMsg());
36 function load_info() {
37 $user_info = getProviderInfo($this->user_id
);
39 if (count($user_info)) {
40 //returns array of arrays with 1 array
41 $user_info = $user_info[0];
43 $sql = "SELECT foreign_id,foreign_table FROM integration_mapping where local_table = 'users' and local_id = '" . $this->user_id
. "'";
44 $result = $this->_db
->Execute($sql);
45 if ($result && !$result->EOF
) {
46 $user_info['foreign_update'] = true;
47 $user_info['foreign_id'] = $result->fields
['foreign_id'];
48 $user_info['foreign_table'] = $result->fields
['foreign_table'];
51 $this->data
= array();
55 $this->data
= $user_info;