dealer_tender_list0203.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <?php
  2. include $_SERVER['DOCUMENT_ROOT'].'/common/lib/comm.php';
  3. include $_SERVER['DOCUMENT_ROOT'].'/common/dealer_chk.php';
  4. $s_cd_dealer = $_SESSION['s_cd_dealer'];
  5. $s_cd_dealer_p = $_SESSION['s_cd_dealer_p'];
  6. $s_ds_type = $_SESSION['s_ds_type'];
  7. $s_ds_usertype = $_SESSION['s_ds_usertype'];
  8. $s_ds_company_bp1 = $_SESSION['s_ds_company_bp1'];
  9. $s_ds_branch1 = $_SESSION['s_ds_branch1'];
  10. $s_ds_company_bp2 = $_SESSION['s_ds_company_bp2'];
  11. $s_ds_branch2 = $_SESSION['s_ds_branch2'];
  12. $s_ds_company_bp3 = $_SESSION['s_ds_company_bp3'];
  13. $s_ds_branch3 = $_SESSION['s_ds_branch3'];
  14. $PageNo = $_REQUEST['pageno'];
  15. $PageSize = $_REQUEST['PageSize'];
  16. if (empty($PageNo)) {$PageNo=1;}else{$PageNo=$PageNo;}
  17. if (empty($PageSize)) {
  18. $PageSize=8; //목록개수설정
  19. }else{$PageSize=$PageSize;}
  20. $pagestartpoint=($PageNo-1)*$PageSize;
  21. $sql_from = "";
  22. $sql = "where s.ds_delind='N'";
  23. $orderby = "order by s.dt_insert desc";
  24. $searchtype = $_REQUEST['searchtype'];
  25. $searchword = $_REQUEST['searchword'];
  26. $ds_usertype = $_REQUEST['ds_usertype'];
  27. $ds_status = $_REQUEST['ds_status'];
  28. $ds_type = "A0"; //A0 : 매입
  29. $sql = $sql. " and s.ds_type = '$ds_type' ";
  30. if($ds_status == "E0"){ //입찰하지 않은 판매건
  31. $sql = $sql. " and s.dt_approve >= DATE_ADD(now(), INTERVAL '-".LIMIT_TIME_TENDER."' HOUR) ";
  32. if($s_ds_usertype == "B0"){ //kcar 딜러
  33. $sql = $sql. " and (
  34. (
  35. s.ds_company_bp = '$s_ds_company_bp1' and ds_branch = '$s_ds_branch1'
  36. )
  37. or (
  38. s.ds_company_bp = '$s_ds_company_bp2' and ds_branch = '$s_ds_branch2'
  39. )
  40. or (
  41. s.ds_company_bp = '$s_ds_company_bp3' and ds_branch = '$s_ds_branch3'
  42. )
  43. ) ";
  44. }else{
  45. $sql = $sql. " and s.ds_area in (
  46. select
  47. SUBSTRING_INDEX (SUBSTRING_INDEX(nm_area,',',numbers.n),',',-1)
  48. from
  49. (select 1 n union all select 2
  50. union all select 3 union all select 4
  51. union all select 5 union all select 6
  52. union all select 7 union all select 8
  53. union all select 9 union all select 10
  54. union all select 11 union all select 12
  55. union all select 13 union all select 14
  56. union all select 15 union all select 16
  57. union all select 17 union all select 18
  58. union all select 19 union all select 20
  59. ) numbers INNER JOIN dealer_master
  60. on CHAR_LENGTH ( nm_area ) - CHAR_LENGTH ( REPLACE ( nm_area , ',' , '' ))>= numbers . n-1
  61. where cd_dealer = $s_cd_dealer_p
  62. ) ";
  63. }
  64. }
  65. if($s_ds_type == "D0"){ //딜러
  66. $sql_ds_type = " and cd_dealer_p = '$s_cd_dealer' ";
  67. }else{ //딜러-관리자
  68. $sql_ds_type = " and cd_dealer = '$s_cd_dealer' ";
  69. }
  70. if($searchword != ""){
  71. if($searchtype=="" || $searchtype==null){
  72. $sql = $sql. " and (s.nm_name like '$searchword%' or a.nm_number like '$searchword%') ";
  73. }else{
  74. $sql = $sql. " and $searchtype like '$searchword%'";
  75. }
  76. }
  77. if($ds_usertype != ""){
  78. $sql = $sql. " and s.ds_usertype = '$ds_usertype'";
  79. }
  80. if($ds_status == "E0"){ //딜러 업체 소속 입찰 건이 2건 보다 작을 시만 입찰 요청 건에 보이게 한다. //입찰하지 않은 판매건
  81. $sql = $sql. " and s.ds_status in ('E0','F0')";
  82. //딜러 업체 소속 입찰 건이 2건 보다 작을 시만 입찰 요청 건에 보이게 한다.
  83. $sql_from = $sql_from. " left outer join ( ";
  84. $sql_from = $sql_from. " select cd_sale from tender_master where ds_delind = 'N' and cd_dealer_p = '$s_cd_dealer_p' group by cd_sale having count(*) > 1) f ";
  85. $sql_from = $sql_from. " on (s.cd_sale = f.cd_sale) ";
  86. $sql = $sql. " and f.cd_sale is null "; //딜러 업체 소속 입찰 건이 2건 보다 작을 시만 입찰 요청 건에 보이게 한다.
  87. if($s_ds_type == "D1"){ //딜러-관리자
  88. //본인 입찰 건 제외한 입찰 건
  89. $sql_from = $sql_from. " left outer join ( ";
  90. $sql_from = $sql_from. " select cd_sale from tender_master where ds_delind = 'N' and cd_dealer = '$s_cd_dealer' group by cd_sale) g ";
  91. $sql_from = $sql_from. " on (s.cd_sale = g.cd_sale) ";
  92. $sql = $sql. " and g.cd_sale is null "; //본인 입찰 건 제외한 입찰 건
  93. }
  94. }else{
  95. if($ds_status == "F0"){ //입찰 중인 판매건
  96. $sql = $sql. " and s.ds_status in ('E0','F0')";
  97. // $sql = $sql. " and s.cd_sale in (select cd_sale from tender_master where ds_delind = 'N' ".$sql_ds_type." group by cd_sale)"; //20191001이전 지연 쿼리
  98. $sql = $sql. " and exists(select cd_sale from tender_master where cd_sale = s.cd_sale and ds_delind = 'N' ".$sql_ds_type." )"; //20191001 cd_sale_cd_user_cd_dealer index 설정 후 쿼리 변경
  99. }else if($ds_status == "Z0"){ //낙찰된 판매건
  100. $sql = $sql. " and s.ds_status in ('Z0')";
  101. $sql_from = $sql_from. " inner join ( ";
  102. $sql_from = $sql_from. " select cd_sale from tender_master where ds_delind = 'N' and ds_status in ('Z0') ".$sql_ds_type." group by cd_sale) h ";
  103. $sql_from = $sql_from. " on (s.cd_sale = h.cd_sale) ";
  104. // $sql = $sql. " and h.cd_sale is not null ";
  105. }else if($ds_status == "ZS"){ //구매 확정된 판매건
  106. // $sql = $sql. " and s.ds_status in ('Z0')";
  107. // $sql = $sql. " and s.ds_status_contract in ('Z0')";
  108. $sql = $sql. " and s.ds_status in ('ZS')";
  109. $sql_from = $sql_from. " inner join ( ";
  110. $sql_from = $sql_from. " select cd_sale from tender_master where ds_delind = 'N' and ds_status in ('Z0') ".$sql_ds_type." group by cd_sale) i ";
  111. $sql_from = $sql_from. " on (s.cd_sale = i.cd_sale) ";
  112. // $sql = $sql. " and i.cd_sale is not null ";
  113. }else{
  114. $sql = $sql. " and 1!=1 ";
  115. }
  116. }
  117. if($ds_status == "E0"){
  118. $nm_title = "입찰대기 리스트";
  119. }else if($ds_status == "F0"){
  120. $nm_title = "입찰중 리스트";
  121. }else if($ds_status == "Z0"){
  122. $nm_title = "낙찰 리스트";
  123. }else if($ds_status == "ZS"){
  124. $nm_title = "구매확정 리스트";
  125. }
  126. $totalrows = @mysql_result(mysql_query("select count(*) from sale_master s inner join car_master a on ( s.cd_car = a.cd_car ) $sql_from $sql"),0,0);
  127. ?>
  128. <? include("../include/inc_top.php") ?>
  129. <? include("../include/inc_header.php") ?>
  130. <section id="wrap">
  131. <section id="visual" class="visual_mypage">
  132. <h2>마이페이지</h2>
  133. <p>쉽고 간편한 내차팔기, 견적산출, 최종 매각까지 어떤 수수료도 요구하지 않습니다.</p>
  134. </section>
  135. <section id="content">
  136. <ul class="location">
  137. <li><a href="/" class="home">홈</a></li>
  138. <li><span class="depth1">마이페이지</span>
  139. <ul class="sub_depth">
  140. <li><a href="#">마이페이지</a></li>
  141. <li><a href="#">입찰정보</a></li>
  142. <li><a href="#">차량정보</a></li>
  143. <li><a href="#">문의내역</a></li>
  144. </ul>
  145. </li>
  146. <li><span class="depth2">딜러</span></li>
  147. </ul>
  148. <? include("./inc_menu_dealer.php") ?>
  149. <h3><?=$nm_title?></h3>
  150. <div class="select_sort">
  151. <span class="select">
  152. <select>
  153. <option value="">최근</option>
  154. <option value="">종료임박순</option>
  155. <option value="">응찰적은순</option>
  156. </select>
  157. </span>
  158. </div>
  159. <ul class="car_list ty2">
  160. <?
  161. if($totalrows>0) {
  162. $r = mysql_query("SELECT
  163. a.*
  164. , b.nm_model
  165. , c.nm_grade
  166. , d.nm_brand
  167. , e.nm_model_sub
  168. , getCode('car_master','ds_type',a.ds_type) as nm_type
  169. , getCode('car_master','ds_open',a.ds_open) as nm_open
  170. , getCode('car_master','ds_sales',a.ds_sales) as nm_sales
  171. , getCode('car_master','ds_transmission',a.ds_transmission) as nm_transmission
  172. , getCode('member_master','ds_area',s.ds_area) as nm_area
  173. , getCode('sale_master','ds_status',s.ds_status) as nm_status
  174. , s.cd_sale
  175. , s.nm_name nm_name_sale
  176. , s.ds_status ds_status_sale
  177. , case when s.ds_status in ('B0','C0') then '미승인' when s.ds_status in ('D0') then '반려' when s.ds_status in ('E0','F0') then case when 'E0' = '$ds_status' then '입찰대기' else '입찰중' end when s.ds_status in ('G0') then '입찰마감' when s.ds_status in ('Z0') then '낙찰' when s.ds_status in ('ZS') then '구매확정' else '' end as nm_status_sale
  178. , case when a.ds_accident in ('A0') then '유' when a.ds_accident in ('B0') then '무' end as nm_act_yn_name
  179. , getRemainTime(".LIMIT_TIME_TENDER.", s.dt_approve, now()) as time_limit_tender
  180. , getRemainTime(".LIMIT_TIME_SELL.", s.dt_approve, now()) as time_limit_sell
  181. , ifnull((select min(nm_price) from tender_master where ds_delind = 'N' and cd_sale = s.cd_sale ".$sql_ds_type."), '') nm_price_tender
  182. FROM sale_master s
  183. inner join car_master a
  184. on (s.cd_car = a.cd_car)
  185. left outer join car_model b
  186. on (a.cd_model = b.cd_model)
  187. left outer join car_grade c
  188. on (a.cd_grade = c.cd_grade)
  189. left outer join car_brand d
  190. on (a.cd_brand = d.cd_brand)
  191. left outer join car_model_sub e
  192. on (a.cd_model_sub = e.cd_model_sub)
  193. $sql_from
  194. $sql $orderby LIMIT $pagestartpoint,$PageSize");
  195. $i=1;
  196. while($col = mysql_fetch_array($r)) {
  197. $tmpNum =$totalrows-($PageSize*($PageNo-1));
  198. $no = ($tmpNum - $i)+1;
  199. ?>
  200. <?
  201. if($col[ds_status_sale] == "ZS"){
  202. ?>
  203. <li onclick="location.href='./dealer_tender_view3.php?list_url=<?=$list_url?>&cd_sale=<?=$col[cd_sale]?>&ds_status_sale=<?=$col[ds_status_sale]?>&ds_status=<?=$ds_status?>&ListPageNo=<?=$PageNo?>';" style="cursor:pointer;">
  204. <?
  205. }else if($col[ds_status_sale] == "Z0"){
  206. ?>
  207. <li onclick="location.href='./dealer_tender_view2.php?list_url=<?=$list_url?>&cd_sale=<?=$col[cd_sale]?>&ds_status_sale=<?=$col[ds_status_sale]?>&ds_status=<?=$ds_status?>&ListPageNo=<?=$PageNo?>';" style="cursor:pointer;">
  208. <?
  209. }else{
  210. ?>
  211. <li onclick="location.href='./dealer_tender_view.php?list_url=<?=$list_url?>&cd_sale=<?=$col[cd_sale]?>&ds_status_sale=<?=$col[ds_status_sale]?>&ds_status=<?=$ds_status?>&ListPageNo=<?=$PageNo?>';" style="cursor:pointer;">
  212. <?
  213. }
  214. ?>
  215. <span class="thumb"><img src="<?=UPLOAD_PATH_CAR?>nm_file_main/ratio/<?=$col[nm_file_front]?>" alt=""></span>
  216. <dl>
  217. <dt><?=$col[nm_model]." ".$col[nm_model_sub]." ".$col[nm_grade]?></dt>
  218. <dd>주행거리 : <?=$col[nm_mileage]?>km</dd>
  219. <dd>최초등록일 : <?=$col[nm_regdate_mm]?> / <?=$col[nm_regdate_yyyy]?></dd>
  220. <dd>사고유무 : <?=$col[nm_act_yn_name]?></dd>
  221. <dd>판매지역 : <?=$col[nm_area]?></dd>
  222. <?
  223. if($ds_status != "E0"){ //입찰하지 않은 판매건
  224. ?>
  225. <dd>입찰금액 : <?=$col[nm_price_tender]?>만원 </dd>
  226. <?
  227. }
  228. ?>
  229. <? if($ds_status == "E0" || $ds_status == "F0"){ ?>
  230. <dd>마감시간 : <?=$col[time_limit_tender]?></dd>
  231. <? } ?>
  232. </dl>
  233. <div class="flag">
  234. <? if($col[time_limit_sell]=="0분" && ($col[ds_status_sale] == "E0" || $col[ds_status_sale] == "F0")){ ?>
  235. 거래마감
  236. <? }else{ ?>
  237. <?=$col[nm_status_sale]?>
  238. <? } ?>
  239. </div>
  240. </li>
  241. <?
  242. $i++;
  243. }
  244. }else{
  245. ?>
  246. <li class="info_no">
  247. 등록된 정보가 없습니다.
  248. </li>
  249. <?
  250. }
  251. ?>
  252. </ul>
  253. <div class="paging">
  254. <?
  255. $url = "./dealer_tender_list.php?searchtype=$searchtype&searchword=$searchword&ds_status=$ds_status&ds_usertype=$ds_usertype";
  256. ListPg1($url ,$PageNo,$PageSize,10,$totalrows,$leftboard[1],$rootpath);
  257. ?>
  258. </div>
  259. </section>
  260. </section>
  261. <font color="white"><?= "" ?></font>
  262. <? include("../include/inc_footer.php") ?>
  263. <? include("../include/inc_bottom.php") ?>
  264. <?
  265. mysql_close($connect);
  266. ?>