-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXeroItem.php
86 lines (69 loc) · 2.27 KB
/
XeroItem.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
class XeroItem {
//ATTRIBUTES
public $_title = 'Items';
public $_pk = 'xeroItemID'; //our primary key title
protected $_table = 'xeroitem'; //MySQL table name
//OUR FIELDS
public $xeroItemID = ''; //Our primary Key
public $userID = 0;
//XERO Fields
public $ItemID; //Xero's primary key
public $Code;
public $Description;
public $PurchaseDetails_UnitPrice;
public $PurchaseDetails_AccountCode;
public $SalesDetails_UnitPrice;
public $SalesDetails_AccountCode;
function __construct($dataarray,$userID)
{
// Intitlize all the variable
// print_r($dataarray);
foreach($dataarray->Item as $row)
{
$this->ItemID=$row->ItemID;
$this->Code=$row->Code;
$this->Description=$row->Description;
if(isset($row->PurchaseDetails->UnitPrice))
{
$this->PurchaseDetails_UnitPrice=$row->PurchaseDetails->UnitPrice;
}
if(isset($row->PurchaseDetails->AccountCode))
{
$this->PurchaseDetails_AccountCode=$row->PurchaseDetails->AccountCode;
}
if(isset($row->SalesDetails->UnitPrice))
{
$this->SalesDetails_UnitPrice=$row->SalesDetails->UnitPrice;
}
if(isset($row->SalesDetails->AccountCode))
{
$this->SalesDetails_AccountCode=$row->SalesDetails->AccountCode;
}
//echo $this->AccountID."<br> sdfsdsd ";
$this->insert();
}
return true;
}
//CRUD
public function insert(){
$insert = sprintf("INSERT INTO ".$this->_table."
(userID, ItemID, Code, Description , PurchaseDetails_UnitPrice,PurchaseDetails_AccountCode,SalesDetails_UnitPrice,SalesDetails_AccountCode)
VALUES
('%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s');",
mysql_real_escape_string($this->userID),
mysql_real_escape_string($this->ItemID),
mysql_real_escape_string($this->Code),
mysql_real_escape_string($this->Description),
mysql_real_escape_string($this->PurchaseDetails_UnitPrice),
mysql_real_escape_string($this->PurchaseDetails_AccountCode),
mysql_real_escape_string($this->SalesDetails_UnitPrice),
mysql_real_escape_string($this->SalesDetails_AccountCode)
);
$result = mysql_query($insert);
}
/*
Any other utilities you need here
*/
}
?>