-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimportFromXML.php
140 lines (132 loc) · 4.41 KB
/
importFromXML.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
$path = "";
header('Content-Type: text/html; charset=utf-8');
/*if(file_exists("teste.xml")) {
$xml=simplexml_load_file("teste.xml");*/
$url = $_POST['url'];
$xml = new SimpleXMLElement($url, null, true);
foreach ($xml->children() as $child) {
echo $child->getName();
if($child->getName() == 'MasterFiles') {
foreach ($child->children() as $child1) {
echo $child1->getName();
if($child1->getName() == 'Customer') {
foreach ($child1->children() as $child2) {
if( $child2->getName() == 'CustomerID' ) {
$CustomerID = $child2;
//$path = '?CustomerID=' . $CustomerID;
$pathCustID = '&CustomerID=' . $CustomerID;
}
if( $child2->getName() == 'CustomerTaxID' ) {
$CustomerTaxID = $child2;
//$path .= '&CustomerTaxID=' . $CustomerTaxID;
}
if( $child2->getName() == 'CompanyName' ) {
$CustomerName = $child2;
//$path .= '&CustomerName=' . $CustomerName;
}
if( $child2->getName() == 'BillingAddress' ) {
$CustomerAddressDetail = $child2->AddressDetail;
//$path .= '&CustomerAddressDetail=' . $CustomerAddressDetail;
$CustomerCity = $child2->City;
//$path .= '&CustomerCity=' . $CustomerCity;
$CustomerPostalCode = $child2->PostalCode;
//$path .= '&CustomerPostalCode=' . $CustomerPostalCode;
$CustomerCountry = $child2->Country;
//$path .= '&CustomerCountry=' . $CustomerCountry;
}
if( $child2->getName() == 'Email' ) {
$CustomerEmail = $child2;
//$path .= '&CustomerEmail=' . $CustomerEmail;
}
}
}
}
}
}
foreach ($xml->SourceDocuments->children() as $child) {
foreach ($child->children() as $child2) {
if($child2->getName() == 'Invoice') {
foreach ($child2->children() as $child3) {
if($child3->getName() == 'InvoiceNo') {
$InvoiceNo = $child3;
//$path .= '&InvoiceNo=' . $InvoiceNo;
}
if($child3->getName() == 'InvoiceDate') {
$InvoiceDate = $child3;
//$path .= '&InvoiceDate=' . $InvoiceDate;
$path .= '?InvoiceDate=' . $InvoiceDate . $pathCustID;
}
if($child3->getName() == 'CustomerID') {
$InvoiceCustomerID = $child3;
//$path .= '&InvoiceCustomerID=' . $InvoiceCustomerID;
}
if($child3->getName() == 'Line') {
foreach ($child3->children() as $child4) {
if($child4->getName() == 'LineNumber') {
$LineNumber = $child4;
//$path .= '&LineNumber=' . $LineNumber;
}
if($child4->getName() == 'ProductCode') {
$ProductCode = $child4;
$path .= '&ProductCode[]=' . $ProductCode;
}
if($child4->getName() == 'ProductDescription') {
$ProductDescription = $child4;
// $path .= '&ProductDescription=' . $ProductDescription;
}
if($child4->getName() == 'Quantity') {
$Quantity = $child4;
$path .= '&Quantity[]=' . $Quantity;
}
if($child4->getName() == 'UnitOfMeasure') {
$UnitOfMeasure = $child4;
//$path .= '&UnitOfMeasure=' . $UnitOfMeasure;
}
if($child4->getName() == 'UnitPrice') {
$UnitPrice = $child4;
$path .= '&UnitPrice[]=' . $UnitPrice;
}
if($child4->getName() == 'CreditAmount') {
$CreditAmount = $child4;
//$path .= '&CreditAmount=' . $CreditAmount;
}
if($child4->getName() == 'Tax') {
foreach ($child4->children() as $child5) {
if($child5->getName() == 'TaxType') {
$TaxType = $child5;
$path .= '&TaxType[]=' . $TaxType;
}
if($child5->getName() == 'TaxPercentage') {
$TaxPercentage = $child5;
$path .= '&TaxPercentage[]=' . $TaxPercentage;
}
}
}
}
}
//END OF LINES
if($child3->getName() == 'DocumentTotals') {
foreach ($child3->children() as $child4) {
if($child4->getName() == 'TaxPayable' ) {
$TaxPayable = $child4;
$path .= '&TaxPayable=' . $TaxPayable;
}
if($child4->getName() == 'NetTotal' ) {
$NetTotal = $child4;
$path .= '&NetTotal=' . $NetTotal;
}
if($child4->getName() == 'GrossTotal' ) {
$GrossTotal = $child4;
// $path .= '&GrossTotal=' . $GrossTotal;
}
}
}
}
}
}
}
echo $path;
$redirect_url = "createInvoice.php" . $path;
header("Location: " . $redirect_url);
?>