ÿØÿà JFIF  ` ` ÿþš 403 WEBHELL REBORN
403 WEBHELL REBORN
Server : Apache
System : Linux ruga7-004.fmcity.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User : tkt_travelbus ( 1137)
PHP Version : 7.0.0p1
Disable Function : mysql_pconnect
Directory :  /tkt_travelbus/www/admin/cal/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

Buat Folder Baru:
Buat File Baru:

Current File : /tkt_travelbus/www/admin/cal/b2b_month_cal.html
<?php
include "../include/top.html";


//쿠팡
/*$sql = "select g_uid FROM TB_RES_GOOD WHERE agent_id = 'coupang' group by g_uid";
$res = db_query($sql);

$goodListStr = "";
while($row = db_fetch_array($res)){
    if(!$goodListStr){
        $goodListStr = $row['g_uid'];
    }else{
        $goodListStr .= ",".$row['g_uid'];
    }
}

$sql = "SELECT b_uid FROM good WHERE g_uid IN ($goodListStr) GROUP BY b_uid";
$res = db_query($sql);

while($row = db_fetch_array($res)){
    p($row['b_uid']);
}*/

/*
 *
117 자유여행
152 자유여행
153 할인티켓
157 외식쿠폰
*
*/
//exit;

if($period_yy == ""){
    $period_yy = date('Y');
}

if($period_mm == ""){
    $period_mm = date('m');
}

$period = $period_yy . "-" . $period_mm;

// 관리자
//$admin_arr = member_fetch(" and mb_level <= 10 and del_flag='N' ");

$nat = 'KO';
$natWord = "국내";
if(strpos($_SERVER['REQUEST_URI'], 'overseas') !== false){
    //거래처
    $natWord = "해외";
    $agent_list = member_fetch(" and mb_level='12' AND bz_nat != '{$nat}'");
}else{
    $agent_list = member_fetch(" and mb_level='12' AND bz_nat = '{$nat}'");
}

//p($agent_list);

$agentList = array();
foreach($agent_list as $item){
    $agentList[$item['mb_id']] = $item['bz_corp_nm'];
}

//$data_agent = array();

$agentSellList = array();

foreach($agent_list as $item){
    $agentSellList[$item['mb_id']]['mb_id'] = $item['mb_id'];
    $agentSellList[$item['mb_id']]['name'] = $item['bz_corp_nm'];
    $agentSellList[$item['mb_id']]['bz_nat'] = $item['bz_nat'];

//    $agentSellList[$item['mb_id']]['T'] = array('cnt' => 0, 'amount' => 0); //Ticket Pass
//    $agentSellList[$item['mb_id']]['D'] = array('cnt' => 0, 'amount' => 0); //Day Tour
//    $agentSellList[$item['mb_id']]['P'] = array('cnt' => 0, 'amount' => 0); //Bus Tour
//    $agentSellList[$item['mb_id']]['L'] = array('cnt' => 0, 'amount' => 0); //Hotel
//    $agentSellList[$item['mb_id']]['S'] = array('cnt' => 0, 'amount' => 0); //Pickup
//    $agentSellList[$item['mb_id']]['R'] = array('cnt' => 0, 'amount' => 0); //Rentcar
//    $agentSellList[$item['mb_id']]['V'] = array('cnt' => 0, 'amount' => 0); //Live Tour
    $agentSellList[$item['mb_id']] = array('totalCnt' => 0, 'totalAmount' => 0); //total
}


//p($agentSellList);
//exit;

$sql = "SELECT g_uid, b_uid, m_uid, s_uid FROM good";
$goodRes = db_query($sql);

$goodInfoList = array();

while($row = db_fetch_array($goodRes)){
    $goodInfoList[$row['g_uid']] = $row;
}


$start_ym = $period_yy.'-'.$period_mm;
$end_ym = $period_yy.'-'.$period_mm;
$res_data = TO_get_reserv_data_b2b($start_ym, $end_ym);


//p($res_data);
//exit;


/*foreach($res_data as $item) {
    $agentSellList[$item['agent_id']][$item['tab']]['cnt'] += 1;
    $agentSellList[$item['agent_id']][$item['tab']]['amount'] += (int) $item['buy_total'];
    $agentSellList[$item['agent_id']]['totalCnt'] += 1;
    $agentSellList[$item['agent_id']]['totalAmount'] += (int) $item['buy_total'];
}*/


foreach($res_data as $item) {

//    p($item['agent_id']);
    if($item['agent_id'] == ''){
        $item['agent_id'] = 'tktravel';
    }

    if($goodInfoList[$item['g_uid']]['b_uid'] == null){
        continue;
    }

//    p($goodInfoList[$item['g_uid']]['b_uid']);

    if(!isset($agentSellList[$item['agent_id']][$goodInfoList[$item['g_uid']]['b_uid']]['cnt'])){
        $agentSellList[$item['agent_id']][$goodInfoList[$item['g_uid']]['b_uid']]['cnt'] = 0;
    }
    if(!isset($agentSellList[$item['agent_id']][$goodInfoList[$item['g_uid']]['b_uid']]['cnt'])){
        $agentSellList[$item['agent_id']][$goodInfoList[$item['g_uid']]['b_uid']]['amount'] = 0;
    }

    $agentSellList[$item['agent_id']][$goodInfoList[$item['g_uid']]['b_uid']]['cnt'] += 1;

    if($item['agent_id'] == 'tourboss'){

        if($goodInfoList[$item['g_uid']]['b_uid'] == 162 || $goodInfoList[$item['g_uid']]['b_uid'] == 114){
//            $resTotalAgent = (int) $item['gdt_pe_daesu'] * (int) $item['adult_agent'];

            if(!$item['gdt_pe_daesu']){
                $resTotalAgent = (int) ($item['personAdult'] * (int) $item['adult_agent']) + ($item['personChild'] * (int) $item['child_agent']) + ($item['personBaby'] * (int) $item['baby_agent']);
            }else{
                $resTotalAgent = (int) $item['gdt_pe_daesu'] * (int) $item['adult_agent'];
            }


        }else{
            $resTotalAgent = (int) ($item['personAdult'] * (int) $item['adult_price']) + ($item['personChild'] * (int) $item['child_price']) + ($item['personBaby'] * (int) $item['baby_price']);
        }

        $agentSellList[$item['agent_id']][$goodInfoList[$item['g_uid']]['b_uid']]['amount'] += (int) $resTotalAgent;
    }else{

        if($goodInfoList[$item['g_uid']]['b_uid'] == 162 || $goodInfoList[$item['g_uid']]['b_uid'] == 114){

            if(!$item['gdt_pe_daesu']){
                $resTotalAgent = (int) ($item['personAdult'] * (int) $item['adult_agent']) + ($item['personChild'] * (int) $item['child_agent']) + ($item['personBaby'] * (int) $item['baby_agent']);
            }else{
                $resTotalAgent = (int) $item['gdt_pe_daesu'] * (int) $item['adult_agent'];
            }

        }else{
            $resTotalAgent = (int) ($item['personAdult'] * (int) $item['adult_agent']) + ($item['personChild'] * (int) $item['child_agent']) + ($item['personBaby'] * (int) $item['baby_agent']);
        }




        $agentSellList[$item['agent_id']][$goodInfoList[$item['g_uid']]['b_uid']]['amount'] += (int) $resTotalAgent;
    }

    $agentSellList[$item['agent_id']]['totalCnt'] += 1;
    $agentSellList[$item['agent_id']]['totalAmount'] += (int) $resTotalAgent;

    if($item['res_no']){
        $resOptionData = getResOption($item['res_no']);
        if(count($resOptionData) > 0){
            foreach($resOptionData as $opItem){
                if($opItem['op_num'] > 0){
                    $opPriceAgent = (int) $opItem['op_price_agent'];
                    $opNum = (int) $opItem['op_num'];
                    if($opNum == 0 || $opPriceAgent == 0){
                        continue;
                    }
                    $agentSellList[$item['agent_id']]['totalAmount'] += $opPriceAgent * $opNum;
                }

            }
        }
    }

}


function getResOption($resNo){
    $sql = "SELECT * FROM TB_RES_GOOD_OPTION WHERE res_no = '{$resNo}'";
    $res = db_query($sql);

    $resturnData = array();
    while($row = db_fetch_array($res)){
        array_push($resturnData, $row);
    }
    return $resturnData;
}


//p($agentSellList);
/*$agentSellListArr = array();
foreach($agentSellList as $item){
    array_push($agentSellListArr, $item);
}
p($agentSellListArr);*/
//p($agentSellList);

$agentSellListArr = array();

foreach($agentSellList as $key => $item){
    $agentSellListArr[] = array('agentName' => $key, 'data' => $item, 'totalAmount' => $item['totalAmount']);
}

//p($agentSellListArr);
//exit;

$agentSellListArr = arr_sort($agentSellListArr, 'totalAmount','desc');


$agentSellList = array();
foreach($agentSellListArr as $value){
    $agentSellList[$value['agentName']] = $value['data'];
}

foreach($agentSellList as $key => $item){
//    p($key);
//    p($item);
//    153 할인티켓
//    157 외식쿠폰
    //외식쿠폰 데이터를 할인티켓에 합침.

    if(isset($item['153']) && isset($item['157'])){
        $agentSellList[$key]['153']['amount'] += $agentSellList[$key]['157']['amount'];
        $agentSellList[$key]['153']['cnt'] += $agentSellList[$key]['157']['cnt'];
    }
    else if(!isset($item['153']) && isset($item['157'])){
        $agentSellList[$key]['153']['amount'] = 0;
        $agentSellList[$key]['153']['cnt'] = 0;
        $agentSellList[$key]['153']['amount'] += $agentSellList[$key]['157']['amount'];
        $agentSellList[$key]['153']['cnt'] += $agentSellList[$key]['157']['cnt'];
    }else if(isset($item['153']) && !isset($item['157'])){

    }



}



//p($agentSellList);
//exit;


function arr_sort($array, $key, $sort='asc') {
    $keys = array();
    $vals = array();

    foreach ($array as $k=>$v) {
        $i = $v[$key].'.'.$k;
        $vals[$i] = $v;
        array_push($keys, $k);
    }

    unset($array);

    if ($sort=='asc') {
        ksort($vals);
    } else {
        krsort($vals);
    }

    $ret = array_combine($keys, $vals);
    unset($keys);
    unset($vals);

    return $ret;
}


//데이터가 안나오게 하기 위함
$agentSellList = array();

?>

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<!--<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>-->
<!--<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@2.0.0"></script>-->

<style>
    input[type="number"]::-webkit-outer-spin-button,
    input[type="number"]::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }
    .minusTotalCnt, .minusTotalAmount{border:1px solid #ccc}
    .minusTotalCnt {width:20px;text-align:center}
    .minusTotalAmount {width:63px;text-align:right}

    .form_in_btn li a{width: 62px !important;}

    /*#Content_box{display:none}*/
</style>
<div class="contents_wrap">
    <div class="contents_wrap_in">
        <div class="title"><strong>B2B 거래처(<?=$natWord?>) 월별정산내역</strong></div>

        <div class="contents_detail">

            <!-- 폼 -->
<!--            <form name="frm_search" id="frm_search" method="get">-->
                <input type="hidden" name="period_mm" id="period_mm" value="<?=$period_mm?>">
                <div class="c_top_bar_search">
                    <table width="" border="0" cellpadding="0" cellspacing="0" summary="여행상품 예약관리 통합검색입니다." class="c_top_table">
                        <caption>여행상품 예약관리 통합검색</caption>

                        <tbody>
                        <tr class="bot_line">
                            <th style="width:150px">검색년월</th>
                            <td><ul class="form_list">
                                    <li class="mr5">
                                        <select name="period_yy" id="item_period_yy">
                                            <? for ($yy=date('Y'); $yy >= 2018; $yy--){ ?>
                                                <option value="<?=$yy?>" <?=($yy==$period_yy) ? "selected":""?>><?=$yy?>년</option>
                                            <? }?>
                                        </select>
                                    </li>
                                    <li>
                                        <ul class="form_in_btn item_period_mm">
                                            <? for($s=1 ; $s<=12 ; $s++){?>
                                                <li class="<?if($s==$period_mm)echo "on";?>" month="<?=$s?>"><a href="javascript:;"><?=$s?>월</a></li>
                                            <? }?>
                                        </ul>
                                    </li>
                                </ul>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </form>
            <!-- /폼 -->
            <?php
            $totalAreaColor = "#";
            ?>

            <style>
                .t_list th{;padding:2px 10px !important;text-align:center;background:#e0eaf6}
                .th2{text-align:center !important}
                .t_list th{font-weight:bold}
            </style>

            <div id="Content_box">
                <form name="frm_reserv_good" id="frm_reserv_good" enctype="multipart/form-data" method="post">
                    <input type="hidden" name="period_yy" id="period_yy" value="<?=$period_yy?>">
                    <input type="hidden" name="period_mm" id="period_mm" value="<?=$period_mm?>">

                    <h2 class="mt30">▍<?=$period_yy?>년 <?=$period_mm?>월 거래처 매출 내역</h2>

                    <?php
                    $amountWidth = "70px";
                    ?>
                    <table style="width:1100px" border="0" cellspacing="0" cellpadding="0" class="t_list">
                        <thead>
                        <tr>
                            <th style="border-top:2px solid #000;width:150px;border-right:1px solid #ccc !important;" rowspan="2">거래처명</th>
                            <th style="border-top:2px solid #000;border-right:1px solid #ccc !important;" colspan="2">자유여행</th>
                            <th style="border-top:2px solid #000;border-right:1px solid #ccc !important;" colspan="2">버스여행</th>
                            <th style="border-top:2px solid #000;border-right:1px solid #ccc !important;" colspan="2">티켓</th>
                            <th style="border-top:2px solid #000;border-right:1px solid #ccc !important;" colspan="2">공항픽업</th>
                            <th colspan="2" style="border-top:2px solid #000;_background:#fffde1;border-right:1px solid #ccc !important;">버스렌트</th>
                            <th colspan="2" style="border-top:2px solid #000;background:#fff7f7;border-right:1px solid #ccc !important;">총합계</th>
                            <th rowspan="2" style="border-top:2px solid #000;width:88px;background:#555;color:#fff">인보이스</th>
                        </tr>
                        <tr>
                            <th class="th2">수량</th>
                            <th style="width:<?=$amountWidth?>;border-right:1px solid #ccc !important;" class="th2">금액</th>
                            <th>수량</th>
                            <th style="width:<?=$amountWidth?>;border-right:1px solid #ccc !important;">금액</th>
                            <th>수량</th>
                            <th style="width:<?=$amountWidth?>;border-right:1px solid #ccc !important;">금액</th>
                            <th>수량</th>
                            <th style="width:<?=$amountWidth?>;border-right:1px solid #ccc !important;">금액</th>
                            <th style="_background:#fffde1">수량</th>
                            <th style="width:<?=$amountWidth?>;_background:#fffde1;border-right:1px solid #ccc !important;">금액</th>
                            <th style="background:#fff7f7">수량</th>
                            <th style="width:<?=$amountWidth?>;background:#fff7f7;border-right:1.5px solid #ccc !important;">금액</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php
                        $idx = 1;
                        foreach($agentSellList as $key => $value){
                            if($key == '' || $agentList[$key] == '' || $value['totalAmount'] == 0) {
                                continue;
                            }
                        ?>
                            <tr>
                                <td style="text-align:left;padding-left:10px;border-right:1px solid #ccc !important;" class="agentName"><?=(($agentList[$key] != '') ? $agentList[$key] : $key)?></td>

                                <?php
                                    //자유여행
                                    $freeTour = 117;

                                    //버스여행
                                    $busTour = 152;

                                    //할인티켓
                                    $ticket = 153;

                                    //공항픽업
                                    $airportTrans = 162;

                                    //버스렌트
                                    $busRent = 114;
                                ?>

                                <td><?=number_format($value[$freeTour]['cnt'])?></td>
                                <td style="text-align: right;border-right:1px solid #ccc !important;"><?=number_format($value[$freeTour]['amount'])?></td>

                                <td><?=number_format($value[$busTour]['cnt'])?></td>
                                <td style="text-align: right"><?=number_format($value[$busTour]['amount'])?></td>

                                <td><?=number_format($value[$ticket]['cnt'])?></td>
                                <td style="text-align: right;border-right:1px solid #ccc !important;"><?=number_format($value[$ticket]['amount'])?></td>

                                <td><?=number_format($value[$airportTrans]['cnt'])?></td>
                                <td style="text-align: right;border-right:1px solid #ccc !important;"><?=number_format($value[$airportTrans]['amount'])?></td>

                                <td><?=number_format($value[$busRent]['cnt'])?></td>
                                <td style="text-align: right;border-right:1px solid #ccc !important;"><?=number_format($value[$busRent]['amount'])?></td>

                                <td style="background:#fff7f7" id="minusTotalCnt<?=$idx?>"><?=number_format($value['totalCnt'])?></td>
                                <td style="text-align:right;background:#fff7f7;border-right:1px solid #ccc !important;" class="agentAmount" id="minusTotalAmount<?=$idx?>"><?=number_format($value['totalAmount'])?></td>

                                <td>
                                    <a href="javascript:;" class="Tbtn" style="background:#206f44;color:#fff;border:1px solid #206f44;padding:5px 19px" onclick="invoice_excel_download('<?=$key?>')">EXCEL <i style="font-size:20px;margin-top:-6px;margin-right:-6px;position:relative;top:4px" class="xi-download"></i></a>
                                </td>
                            </tr>
                            <?php
                            $idx++;
                        }
                        ?>
                        </tbody>
                    </table>

                    <div style="    clear: both;
    float: left;
    margin-top: 10px;">

                        <h2 class="mt30">▍<?=$period_yy?>년 <?=$period_mm?>월 통계 자료</h2>

                        <section id="staticB2bMonthCalArea">

                        </section>

                    </div>


                    <style>
                        /*line:nth-child(1){stroke:#5AC8DB !important;}*/
                        line:nth-child(2){stroke:#fafafa !important;}
                        line:nth-child(3){stroke:#fafafa !important;}
                        line:nth-child(4){stroke:#fafafa !important;}
                        line:nth-child(5){stroke:#fafafa !important;}
                        line:nth-child(6){stroke:#fafafa !important;}
                        line:nth-child(7){stroke:#fafafa !important;}
                        line:nth-child(8){stroke:#fafafa !important;}
                        line:nth-child(9){stroke:#fafafa !important;}
                        line:nth-child(10){stroke:#fafafa !important;}
                    </style>
                    <?php
                    $chartHeight = "300px";
                    if(strpos($_SERVER['REQUEST_URI'], 'overseas') !== false){
                        $chartHeight = "500px";
                    }
                    ?>
                    <div id="staticB2bMonthCal" style="clear:both;float: left;border: 1px solid #e4e4e4;width: 1100px;height:<?=$chartHeight?>"></div>


                    <script type="text/javascript">
                        google.charts.load('current', {'packages':['bar']});
                        google.charts.setOnLoadCallback(drawChart);


                        agentChartInfo = new Array(['','합계']);
                        // agentChartInfo = new Array();
                        for(i = 0; i < document.getElementsByClassName('agentName').length; i++){

                            console.log(document.getElementsByClassName('agentName')[i].innerText);
                            console.log(document.getElementsByClassName('agentAmount')[i].innerText);

                            agentName = document.getElementsByClassName('agentName')[i].innerText;
                            agentAmount = document.getElementsByClassName('agentAmount')[i].innerText;
                            agentAmount = agentAmount.replaceAll(",","");
                            agentAmount = parseInt(agentAmount);

                            // agentChartInfo.push([agentName,agentAmount,'color: #5AC8DB']);
                            agentChartInfo.push([agentName,agentAmount]);
                            // agentChartInfo.push([agentName,agentAmount]);
                            // agentChartInfo.push([agentName,agentAmount]);
                        }

                        // console.log('agentChartInfo is ' + JSON.stringify(agentChartInfo));

                        /*List.sort(function(a,b) {
                            if (a.AAA*1 > b.AAA*1) return -1;
                            if (a.AAA*1 < b.AAA*1) return 1;
                            return 0;
                        });*/




                        function drawChart() {
                            var data = google.visualization.arrayToDataTable(
                                agentChartInfo
                            );

                            /*var data = google.visualization.arrayToDataTable([
                                ['Element', 'Density', { role: 'style' }],
                                ['Copper', 8.94, '#b87333'],            // RGB value
                                ['Silver', 10.49, 'color: gray'],            // English color name
                                ['Gold', 19.30, 'gold'],
                                ['Platinum', 21.45, 'color: #e5e4e2' ], // CSS-style declaration
                            ]);*/


                            var options = {
                                chart: {
                                    title: '',
                                    subtitle: '',
                                },

                                chartArea: {
                                    backgroundColor: {
                                        fill: '#fafafa',
                                        opacity: 1
                                    },
                                },

                                backgroundColor: {
                                    fill: '#fafafa',
                                    fillOpacity: 1
                                },

                                // width: 600,
                                // height: 500,

                                // lineWidth: 4,
                                // series: [{'color': '#1A8763'}],
                                // intervals: { 'lineWidth':5, 'barWidth': 0.5, style: 'boxes' },

                                bar: {
                                    groupWidth: "25%",
                                    // value: true
                                    // groupHeight: "30px",
                                    // color:'#5AC8DB',
                                },

                                colors: ['#5AC8DB','#5AC8DB'],

                                legend: {position: 'none'},
                                // legend: 'none',
                                // library: {legend:{position:'none'}}


                                bars: 'horizontal' // Required for Material Bar Charts.
                            };

                            var chart = new google.charts.Bar(document.getElementById('staticB2bMonthCal'));

                            chart.draw(data, google.charts.Bar.convertOptions(options));
                        }
                    </script>



<!--                </form>-->




            </div>
        </div>
    </div>

    <iframe name="IMGIF" id="IMGIF" width="0" height="0" style="display:none;"></iframe>


    <script>
        $(window).load(function(){

                $('#item_period_yy').change(function(){
                    period_mm = $('#period_mm').val();
                    location.href = '/admin/cal/b2b_month_cal.html?period_yy=' + $(this).val() + '&period_mm=' + period_mm;
                })

                $('.item_period_mm li').click(function(){
                    if($(this).attr('month').length == 1){
                        period_mm = '0' + $(this).attr('month');
                    }else{
                        period_mm = $(this).attr('month');
                    }
                    period_yy = $('#period_yy').val();
                    location.href = '/admin/cal/b2b_month_cal.html?period_yy=' + period_yy + '&period_mm=' + period_mm;
                })


        })

        function invoice_excel_download(agentID){
            if(!agentID){
                alert('오류 발생 - agent_id가 없습니다.');
                return false;
            }
            var dateterm = $('#period_yy').val() + '-' + $('#period_mm').val();
            var url = "/admin/cal/b2b_month_tb_excel.html?agent_id="+agentID+"&dateterm="+dateterm;

            document.location.href = url;
        }

    </script>
    <?php
    include "../include/footer.html";
    ?>

Anon7 - 2021