dealer_excel.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. $file_name = "딜러리스트_".date("Y-m-d").".xls";
  3. Header("Content-type: charset=utf-8");
  4. Header("Content-type: application/octet-stream");
  5. header( "Content-type: application/vnd.ms-excel;charset=utf-8" );
  6. Header("Content-Disposition: attachment; filename=$file_name");
  7. Header("Pragma: no-cache");
  8. Header("Expires: 0");
  9. header( "Content-Description: PHP5 Generated Data" );
  10. include $_SERVER['DOCUMENT_ROOT'].'/common/lib/comm.php';
  11. include $_SERVER['DOCUMENT_ROOT'].ADMIN_PATH.'common/auth_chk.php';
  12. $mp = "21"; //set top nav
  13. $PageNo =$_REQUEST['pageno'];
  14. $PageSize =$_REQUEST['PageSize'];
  15. if (empty($PageNo)) {$PageNo=1;}else{$PageNo=$PageNo;}
  16. if (empty($PageSize)) {
  17. $PageSize=10; //목록개수설정
  18. }else{$PageSize=$PageSize;}
  19. $pagestartpoint=($PageNo-1)*$PageSize;
  20. $sql = "where ds_delind='N'";
  21. $searchtype = $_REQUEST['searchtype'];
  22. $searchword = $_REQUEST['searchword'];
  23. $ds_status = $_REQUEST['ds_status'];
  24. $dt_start = $_REQUEST['dt_start'];
  25. $dt_end = $_REQUEST['dt_end'];
  26. $ds_type = "D0";
  27. $sql = $sql. " and ds_type = '$ds_type' ";
  28. if($searchword != ""){
  29. if($searchtype=="" || $searchtype==null){
  30. $sql = $sql. " and (nm_name like '$searchword%' or cd_dealerid like '$searchword%') ";
  31. }else{
  32. $sql = $sql. " and $searchtype like '$searchword%'";
  33. }
  34. }
  35. if($ds_status != ""){
  36. if($ds_status == "Z0"){
  37. $sql = $sql. " and ds_status = 'Z0' ";
  38. }else{
  39. $sql = $sql. " and (ds_status is null or ds_status != 'Z0') ";
  40. }
  41. }
  42. if($dt_start != "" && $dt_end != ""){
  43. $sql = $sql. " and dt_insert between '$dt_start' and '$dt_end' ";
  44. }
  45. $totalrows = @mysql_result(mysql_query("select count(*) from dealer_master $sql"),0,0);
  46. ?>
  47. <!DOCTYPE html>
  48. <HTML lang="ko">
  49. <head>
  50. <meta charset="UTF-8" />
  51. </head>
  52. <body>
  53. <table border="1">
  54. <tr>
  55. <th>번호</th>
  56. <th>아이디</th>
  57. <th>상호명</th>
  58. <th>대표자</th>
  59. <th>관리자</th>
  60. <th>관리자 연락처</th>
  61. <th>부관리자</th>
  62. <th>부관리자 연락처</th>
  63. <th>최근입찰시간</th>
  64. </tr>
  65. <?
  66. if($totalrows>0) {
  67. $r = mysql_query("SELECT * FROM dealer_master $sql ORDER BY cd_dealer desc");
  68. $i=1;
  69. while($col = mysql_fetch_array($r)) {
  70. $tmpNum =$totalrows-($PageSize*($PageNo-1));
  71. $sub_dealer_q = "SELECT *
  72. , (SELECT dt_insert FROM tender_master WHERE cd_dealer = d.cd_dealer ORDER BY cd_tender DESC LIMIT 1) as recent_date
  73. FROM dealer_master d
  74. WHERE cd_dealer_p = '$col[cd_dealer]'
  75. ORDER BY cd_dealer desc";
  76. $sub_dealer_r = mysql_query($sub_dealer_q);
  77. $sub_dealer_rows = mysql_num_rows($sub_dealer_r);
  78. $tender_num = 0;
  79. while($sub_dealer_col = mysql_fetch_array($sub_dealer_r)) {
  80. if($tender_num == 0) {
  81. ?>
  82. <tr>
  83. <td rowspan="<?=$sub_dealer_rows?>"><?=$i?></td>
  84. <td rowspan="<?=$sub_dealer_rows?>"><?=$col[cd_dealerid]?></td>
  85. <td rowspan="<?=$sub_dealer_rows?>"><?=$col[nm_company]?></td>
  86. <td rowspan="<?=$sub_dealer_rows?>"><?=$col[nm_name_biz]?></td>
  87. <td rowspan="<?=$sub_dealer_rows?>"><?=$col[nm_name]?></td>
  88. <td rowspan="<?=$sub_dealer_rows?>"><?=$col[nm_hp_01]."-".$col[nm_hp_02]."-".$col[nm_hp_03]?></td>
  89. <td><?=$sub_dealer_col[nm_name]?></td>
  90. <td><?=$sub_dealer_col[nm_hp_01]."-".$sub_dealer_col[nm_hp_02]."-".$sub_dealer_col[nm_hp_03]?></td>
  91. <td><?=$sub_dealer_col[recent_date]?></td>
  92. </tr>
  93. <?
  94. }else {
  95. ?>
  96. <tr>
  97. <td><?=$sub_dealer_col[nm_name]?></td>
  98. <td><?=$sub_dealer_col[nm_hp_01]."-".$sub_dealer_col[nm_hp_02]."-".$sub_dealer_col[nm_hp_03]?></td>
  99. <td><?=$sub_dealer_col[recent_date]?></td>
  100. </tr>
  101. <?
  102. }
  103. $tender_num++;
  104. }
  105. $i++;
  106. }
  107. }else{
  108. ?>
  109. <tr>
  110. <td colspan="9">데이터가 존재 하지 않습니다.</td>
  111. </tr>
  112. <?
  113. }
  114. ?>
  115. </table>
  116. </body>
  117. </html>
  118. <?
  119. mysql_close($connect);
  120. ?>