/home/mjc1/public_html/emillennium/nusoap/samples/client1.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
<?php
session_start
();

$DB_HOSTtax  =  "119.201.210.68";
$DB_USERtax  =  "ebill";
$DB_PWDtax   =  "ebill8680";
$DB_NAMEtax  =  "ebillv3";

$connect_tax    = @mysql_connect($DB_HOSTtax,$DB_USERtax,$DB_PWDtax);
@
mysql_select_db$DB_NAMEtax,$connect_tax);

$DB_HOSTEZ  =  "$ezsa_dbip";
$DB_USEREZ  =  "$ezsa_uid";
$DB_PWDEZ   =  "mj007700";
$DB_NAMEEZ  =  "$ezsa_dbname";

$connect    = @mysql_connect($DB_HOSTEZ,$DB_USEREZ,$DB_PWDEZ);
@
mysql_select_db$DB_NAMEEZ,$connect);

$sql "select * from members where userid = 'ryunen' ";
$res mysql_query($sql,$connect_tax);
$info mysql_fetch_array($res);

print_r($info);

$sql "select * from office limit 1";
$res mysql_query($sql,$connect);
$info mysql_fetch_array($res);

print_r($info);

exit;

$m_nBillPubCodeCnt 0;

function 
add_zero($v,$len){
    
$tmp "";
    for(
$i=$len;$i>strlen($v);$i--){
        
$tmp .= "0";
    }
    return 
$tmp.$v;
}

function 
CreateMessageID(){
    
$datetime date("YmdHis",time())."000-";
    
$rand32 "";
    for(
$i=0;$i<32;$i++){
        
$rand rand(1,15);
        if(
$rand<10){ $rand32.=$rand; }
        else {
            
$rand32.=dechex($rand);
        }
    }
    return 
$datetime.$rand32;

}

function 
make_SubmitID($biz_num=""){
    
$todaydate date("Ymd",time());
    if(
$biz_num==""){ $biz_num "5021894746"; }
    
$rand23 "";
    for(
$i=0;$i<23;$i++){
        
$rand rand(1,15);
        if(
$rand<10){ $rand23.=$rand; }
        else {
            
$rand23.=dechex($rand);
        }
    }
    return 
$todaydate.$biz_num.$rand23;
}

function 
GetEBillPubCode($biz_num="",$sUserCode="00"){
    Global 
$m_nBillPubCodeCnt;
    Global 
$connect_tax;

    
$todaydatetime date("ymdHi",time());
    if(
$biz_num==""){ $biz_num "5021894746"; }
    
$sUserCode $sUserCode// 사용자 코드

    
$pubcode $todaydatetime.$biz_num.$sUserCode;

    
$sql "select SRVC_BUSN_MGMT_NO as num from tn_eaaa where SRVC_BUSN_MGMT_NO like '{$pubcode}%' ";
    
$res mysql_query($sql,$connect_tax);
    
$info mysql_fetch_array($res);

    if(
$info['num']!=''){
        
$pubcodeseq substr($info['num'],22,2);
        
$pubcodeseq = ($pubcodeseq*1)+1;
    } else {
        
$pubcodeseq $m_nBillPubCodeCnt+1;
    }
    
$newseq add_zero($pubcodeseq,2);

    return 
$todaydatetime.$biz_num.$sUserCode.$newseq;
}

$SubmitID  make_SubmitID();
$iCount 1;
$PubCode GetEBillPubCode();
echo 
$PubCode;
$IssueDateTime1 date("YmdHis",time());
$m_sAppcode "160704000200F"// 뭔지모르겠음 SMSSend보내기 "T", "F"
$IssueStatus "S"//발행초기값: I-무시, S-발행
if($debud_mode=="Y"){ // 개발자 모드에서는 국세청에 전송하지 않습니다.
    
$SendStatus "I"//국세청 전송 초기값: I-무시, S-전송
} else {
    
$SendStatus "S";
}
$SendEmail "N"//이메일 전송 초기값: Y-무시, N-전송 (코드값과 의미가 반대임을 주의)
$IssueDateTime2 date("Ymd",time());
$TaxType "0101"//01,02 과세 03,04 면세 그리고 4자리 되어야함 0101 db select 시엔 tn_eaaa테이블의 ETAXBIL_CL_CD필드와 ETAXBIL_KND_CD의 합임..2자리식 4자리
$DemandTag "02"// 01 영수, 02 청구 구분

$sCompanyNum "5021894746";
$sCompanyName "MJSOFT";
$sChiefName "박성원";
$sPerson "박성원";
$sEmail "ryunen@chol.com";
$sPhone "010";
$sCompanyAddr "서울 송파구 오금동 46-9";
$sUptae "도소매";
$sJongmok "일반의약품";

$rCompanyNum "5021894746";
$rCompanyName "미진유통";
$rChiefName "이미진";
$rPerson "박성원";
$rEmail "ryunen@chol.com";
$rPhone "010-9357-0525";
$rCompanyAddr "서울 강동구 천호3동 223-3334445";
$rUptae "도소매2";
$rJongmok "일반의약품2";

$BusinessTypeCode "01"// 01(사업자등록번호),02(주민등록번호), 03(외국인)

$totalprice 10500;
//면세(일반 계산서)와 수정 계산서의 경우에는 세액합계를 표기하지 않음
if(substr($TaxType,0,2)=='01' || substr($TaxType,0,2)=='02'){
    
$totaltax 1050;
} else {
    
$totaltax 0;
}
$cnt=1;
$item_list[$cnt]['item'] = "라이닝(에쿠스350)";
$item_list[$cnt]['offerPrice'] = 68782;
$item_list[$cnt]['billPrice'] = 6878;
$item_list[$cnt]['amount'] = $item_list[$cnt]['offerPrice']+$item_list[$cnt]['billPrice'];
$item_list[$cnt]['cnt'] = 1;
$item_list[$cnt]['date'] = "20160704";
$cnt++;
$item_list[$cnt]['item'] = "라이닝(소나타350)";
$item_list[$cnt]['offerPrice'] = 50000;
$item_list[$cnt]['billPrice'] = 5000;
$item_list[$cnt]['amount'] = $item_list[$cnt]['offerPrice']+$item_list[$cnt]['billPrice'];
$item_list[$cnt]['cnt'] = 1;
$item_list[$cnt]['date'] = "20160704";

$item_xml "";
$sumprice $totalprice+$totaltax;
for(
$i=1;$i<=count($item_list);$i++){
    
$item_xml .= "<TaxInvoiceTradeLineItem>
                <SequenceNumeric>
{$i}</SequenceNumeric>
                <InvoiceAmount>
{$item_list[$i]['offerPrice']}</InvoiceAmount>
                <ChargeableUnitQuantity>
{$item_list[$i]['cnt']}</ChargeableUnitQuantity>
                <NameText>
{$item_list[$i]['item']}</NameText>
                <InformationText/>
                <PurchaseExpiryDateTime>
{$item_list[$i]['date']}</PurchaseExpiryDateTime>
                <TotalTax>
                    <CalculatedAmount>
{$item_list[$i]['billPrice']}</CalculatedAmount>
                </TotalTax>
                <UnitPrice>
                    <UnitAmount>
{$item_list[$i]['amount']}</UnitAmount>
                </UnitPrice>
            </TaxInvoiceTradeLineItem>"
;
}

$body_string = <<<XML
    <SubmitID>{$SubmitID}</SubmitID>
    <TotalCount>
{$iCount}</TotalCount>
    <Document>
        <TaxInvoice>
            <ExchangedDocument>
                <ID>
{$PubCode}</ID>
                <IssueDateTime>
{$IssueDateTime1}</IssueDateTime>
                <ReferencedDocument>
                    <ID>
{$m_sAppcode}</ID>
                </ReferencedDocument>
                <IssueStatus>
{$IssueStatus}</IssueStatus>
                <SendStatus>
{$SendStatus}</SendStatus>
                <SendEmail>
{$SendEmail}</SendEmail>
            </ExchangedDocument>
            <TaxInvoiceDocument>
                <IssueID/>
                <TypeCode>
{$TaxType}</TypeCode>
                <IssueDateTime>
{$IssueDateTime2}</IssueDateTime>
                <PurposeCode>
{$DemandTag}</PurposeCode>
            </TaxInvoiceDocument>
            <TaxInvoiceTradeSettlement>
                <InvoicerParty>
                    <ID>
{$sCompanyNum}</ID>
                    <TypeCode>
{$sUptae}</TypeCode>
                    <NameText>
{$sCompanyName}</NameText>
                    <ClassificationCode>
{$sJongmok}</ClassificationCode>
                    <SpecifiedOrganization>
                        <TaxRegistrationID/>
                    </SpecifiedOrganization>
                    <SpecifiedPerson>
                        <NameText>
{$sChiefName}</NameText>
                    </SpecifiedPerson>
                    <DefinedContact>
                        <PersonNameText>
{$sPerson}</PersonNameText>
                        <TelephoneCommunication>
{$sPhone}</TelephoneCommunication>
                        <URICommunication>
{$sEmail}</URICommunication>
                    </DefinedContact>
                    <SpecifiedAddress>
                        <LineOneText>
{$sCompanyAddr}</LineOneText>
                    </SpecifiedAddress>
                </InvoicerParty>
                <InvoiceeParty>
                    <ID>
{$rCompanyNum}</ID>
                    <TypeCode>
{$rUptae}</TypeCode>
                    <NameText>
{$rCompanyName}</NameText>
                    <ClassificationCode>
{$rJongmok}</ClassificationCode>
                    <SpecifiedOrganization>
                        <TaxRegistrationID/>
                        <BusinessTypeCode>
{$BusinessTypeCode}</BusinessTypeCode>
                    </SpecifiedOrganization>
                    <SpecifiedPerson>
                        <NameText>
{$rChiefName}</NameText>
                    </SpecifiedPerson>
                    <PrimaryDefinedContact>
                        <PersonNameText>
{$rPerson}</PersonNameText>
                        <TelephoneCommunication>
{$rPhone}</TelephoneCommunication>
                        <URICommunication>
{$rEmail}</URICommunication>
                    </PrimaryDefinedContact>
                    <SpecifiedAddress>
                        <LineOneText>
{$rCompanyAddr}</LineOneText>
                    </SpecifiedAddress>
                </InvoiceeParty>
                <SpecifiedMonetarySummation>
                    <ChargeTotalAmount>
{$totalprice}</ChargeTotalAmount>
                    <TaxTotalAmount>
{$totaltax}</TaxTotalAmount>
                    <GrandTotalAmount>
{$sumprice}</GrandTotalAmount>
                </SpecifiedMonetarySummation>
            </TaxInvoiceTradeSettlement>
            
{$item_xml}
        </TaxInvoice>
    </Document>
XML;

/*
 *    $Id: client1.php,v 1.3 2007/11/06 14:48:24 snichol Exp $
 *
 *    Client sample that should get a fault response.
 *
 *    Service: SOAP endpoint
 *    Payload: rpc/encoded
 *    Transport: http
 *    Authentication: none
 */
require_once('../lib/nusoap.php');
$proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : '';
$proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : '';
$proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : '';
$proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : '';
$useCURL = isset($_POST['usecurl']) ? $_POST['usecurl'] : '0';
$client = new nusoap_client("http://119.201.210.68:7000/axis2/services/DocumentService"false,
                        
$proxyhost$proxyport$proxyusername$proxypassword);
$err $client->getError();
if (
$err) {
    echo 
'<h2>Constructor error</h2><pre>' $err '</pre>';
    echo 
'<h2>Debug</h2><pre>' htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
    exit();
}
$client->setUseCurl($useCURL);

$MessageID CreateMessageID(); // "20160727171205000-d60512a264a907ecae38ebe53cd7df1e";
$TimeStamp date("Y-m-d",time())."T".date("H:i:s")."000Z";
$headers "
    <wsa:MessageID>
{$MessageID}</wsa:MessageID>
    <wsa:To>http://119.201.210.68:7000/axis2/services/DocumentService</wsa:To>
    <wsa:Action>http://soap.openet.com</wsa:Action>
    <MessageHeader>
    <Version>3.0</Version>
    <From>
        <PartyID>1208646911</PartyID>
        <PartyName>미진소프트</PartyName>
    </From>
    <To>
        <PartyID>1234567890</PartyID>
        <PartyName>TestBed</PartyName>
    </To>
    <ReplyTo>http://220.90.215.20:7000/axis2/services/TaxService</ReplyTo>
    <OperationType>01</OperationType>
    <MessageType>01</MessageType>
    <TimeStamp>
{$TimeStamp}</TimeStamp>
    </MessageHeader>
"


$client->setHeaders($headers); 
$client->soap_defencoding "utf-8";
$client->decode_utf8 false;

$params $body_string// object 배열로 던지거나 xml스트링으로 던져도 됨

$result $client->call('RequestMessage'$params'''');
if (
$client->fault) {
    echo 
'<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>'print_r($result); echo '</pre>';
} else {
    
$err $client->getError();
    if (
$err) {
        echo 
'<h2>Error</h2><pre>' $err '</pre>';
    } else {
        echo 
'<h2>Result</h2><pre>'print_r($result); echo '</pre>';
    }
}
echo 
'<h2>Request</h2><pre>' htmlspecialchars($client->requestENT_QUOTES) . '</pre>';
echo 
'<h2>Response</h2><pre>' htmlspecialchars($client->responseENT_QUOTES) . '</pre>';
echo 
'<h2>Debug</h2><pre>' htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
?>