/home/mjc1/public_html/emillennium/ajax.tax_buy_process.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
<?php
$dir 
".";
include_once(
$dir."/_common.php");

if(
$smode=='del'){
    
$ml explode(",",$midx_list);
    foreach(
$ml as $key=>$val){
        if(
trim($val)!=''){
            
$sql "delete from buy_tax_m where midx = '{$val}' ";
            
mysql_query($sql,$connect_e1000y);

            
$sql "update buy_d set taxno = NULL where taxno = '{$val}' "
            
mysql_query($sql,$connect_e1000y); // 매입의 세금계산서 링크 삭제
        
}
    }
    echo 
"<script>alert('선택하신 매입 세금계산서가 삭제되었습니다.'); document.location.reload(); </script>";
} else if(
$smode=='new'){

    
$taxno_exists "N";
    
$pname_list "";
    
$dates date("Y-m-d H:i:s",time());

    
$sql "select * from buy_m where midx = '{$midx}' ";
    
$res mysql_query($sql,$connect_e1000y);
    
$buy_info mysql_fetch_array($res);

    
$sql "select * from buy_d where midx = '{$midx}' order by seq ";
    
$res mysql_query($sql,$connect_e1000y);
    
$cnt 0;
    while(
$info mysql_fetch_array($res)){
        if(
$info['taxno']){    $taxno_exists "Y"; }
        if(
$cnt==0){ 
            
$pname_list $info['pname']; 
            
$tax_type $info['tax_type']; 
        }
        
$cnt++;
    }
    if(
$cnt>1){ $pname_list $pname_list."외 ".($cnt-1)."건"; }

    if(
$taxno_exists=='Y'){
        echo 
"<script>alert('해당 전표는 계산서가 이미 발행되었습니다.')</script>"; exit;
    }

    if(
$tax_gubun=='0'){ // 전자세금계산서
        
$card_yn '0';
        
$etax_appv_no '0000000000';
    } else if(
$tax_gubun=='1'){ // 종이세금계산서
        
$card_yn '0';
        
$etax_appv_no '';
    } else if(
$tax_gubun=='2'){ // 카드계산서
        
$card_yn '1';
        
$etax_appv_no '';
    } else if(
$tax_gubun=='3'){ // 현금영수증
        
$card_yn '2';
        
$etax_appv_no '';
    }

    
$sql "insert into buy_tax_m set
                ocode = '
{$buy_info['ocode']}', immd_yn = '0', tax_type = '{$tax_type}', ccode = '{$buy_info['ccode']}',
                writedate = '
{$c_date}', blank = '0', remarks = '{$remarks}', recved_yn = '{$recved_yn}',
                card_yn = '
{$card_yn}', etax_appv_no = '{$etax_appv_no}', cng_reason = '', data_created = '{$dates}',
                data_creator = '0'
    "
;
    
$res mysql_query($sql,$connect_e1000y); // 계산서 마스터 등록
    
$nts_midx mysql_insert_id($connect_e1000y);    

    
$sql "insert into buy_tax_d set
                midx = '
{$nts_midx}', seq = '1', dealdate = '{$c_date}', pname = '{$pname_list}', 
                pnorm = '', unit = '', qty = 0, price = 0, sup_amt = 0, vat = 0, remarks = '',
                data_created = '
{$dates}', data_creator = '0'
    "
;
    
mysql_query($sql,$connect_e1000y); // 계산서 디테일 등록

    
$sql "update buy_d set taxno = '{$nts_midx}' where midx = '{$midx}' ";
    
mysql_query($sql,$connect_e1000y); // 매입에 게산서 매핑 처리

    
echo "<script>alert('매입 세금계산서 처리가 완료되었습니다.'); document.location.reload(); </script>";
}

?>