-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest_print.php
90 lines (72 loc) · 3.39 KB
/
Test_print.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
<?php
header('Content-Type: text/xml; charset=UTF-8');
define("REQUEST_XML_PATH", "demo/request/sample.xml");
define("RESPONSE_XML_PATH", "demo/response/sample.xml");
if (isset($_POST["ConnectionType"])) {
$http_request = $_POST["ConnectionType"];
}
if ($http_request == 'GetRequest') {
# send print data
# ID
#
#
$shop_id = $_POST["ID"];
# create print data
if (file_exists(REQUEST_XML_PATH)) {
# return print data
$handle = fopen(REQUEST_XML_PATH, "r");
fpassthru($handle);
fclose($handle);
# move file
rename(REQUEST_XML_PATH, RESPONSE_XML_PATH);
}
} else if ($http_request == 'SetResponse') {
# get print result
$xml = simplexml_load_string($_POST["ResponseFile"]);
$version = $xml['Version'];
if ($version == '1.00') {
# save log
$fhandle = @fopen("ResultPrint.log", "wt");
fprintf($fhandle, "PrintResponseInfo Version %s\n", $version);
foreach ($xml->response as $response) {
fprintf($fhandle, "----------\nsuccess : %s\ncode : %s\n", $response['success'], $response['code']);
}
fclose($fhandle);
} else if ($version == '2.00') {
# save log
$fhandle = @fopen("ResultPrint.log", "wt");
fprintf($fhandle, "PrintResponseInfo Version %s\n", $version);
foreach ($xml->ePOSPrint as $eposprint) {
$devid = $eposprint->Parameter->devid;
$printjobid = $eposprint->Parameter->printjobid;
$response = $eposprint->PrintResponse->response;
fprintf($fhandle, "----------\ndevid : %s\nprintjobid : %s\nsuccess : %s\ncode : %s\n", $devid, $printjobid, $response['success'], $response['code']);
}
} else if ($version == '3.00') {
# ePOSDisplay tag is only supported by Ver.3.00 or later.
# save log
$fhandle = @fopen("ResultPrint.log", "wt");
fprintf($fhandle, "PrintResponseInfo Version %s\n", $version);
$success = $xml->ServerDirectPrint->Response['Success'];
if($success == 'true') {
# display ePOSDisplay result
foreach ($xml->ePOSDisplay as $eposdisplay) {
$devid = $eposdisplay->Parameter->devid;
$printjobid = $eposdisplay->Parameter->printjobid;
$response = $eposdisplay->DisplayResponse->response;
fprintf($fhandle, "----------\ndevid : %s\nprintjobid : %s\nsuccess : %s\ncode : %s\n", $devid, $printjobid, $response['success'], $response['code']);
}
} else {
# display error summary and detail
$summary = $xml->ServerDirectPrint->Response->ErrorSummary;
$detail = $xml->ServerDirectPrint->Response->ErrorDetail;
fprintf($fhandle, "----------\nServer Direct Print Success : false.\nErrorSummary : %s\nErrorDetail : %s\n", $summary, $detail);
}
fclose($fhandle);
} else {
# Ignore other version
}
} else {
# Ignore other connectionType than GetRequest and SetResponse.
}
?>