inc_ViewTender.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <?php
  2. //이 페이지는 2가지 상황에서 사용됨
  3. //입찰중, 거래중
  4. $cd_sale = $_REQUEST["cd_sale"];
  5. $PageNo = $_REQUEST['pageno'];
  6. $PageSize = $_REQUEST['PageSize'];
  7. if (empty($PageNo)) {$PageNo=1;}else{$PageNo=$PageNo;}
  8. if (empty($PageSize)) {
  9. $PageSize=10; //목록개수설정
  10. }else{$PageSize=$PageSize;}
  11. $pagestartpoint=($PageNo-1)*$PageSize;
  12. $OrderBy = $_REQUEST['OrderBy'];
  13. if ($OrderBy == "") $OrderBy = "cast(t.nm_price as unsigned) desc, t.cd_tender desc ";
  14. $sOrderBy = "ORDER BY ".$OrderBy;
  15. $add_sql = " WHERE d.ds_delind='N' ";
  16. //매물 상태별 처리
  17. $tender_list_title = "";
  18. switch($ds_status_sale) {
  19. //입찰중
  20. case 'F0':
  21. $tender_list_title = "입찰업체";
  22. $add_sql.= " ";
  23. break;
  24. //거래중
  25. case 'Z0':
  26. //낙찰한 상태이면
  27. if(empty($ds_status_contract_step1)) {
  28. $tender_list_title = "입찰업체";
  29. $add_sql.= " ";
  30. }else {
  31. $tender_list_title = "낙찰업체";
  32. $add_sql.= " AND t.ds_status = 'Z0' ";
  33. }
  34. break;
  35. }
  36. $sql = "SELECT count(*)
  37. FROM aap_master d
  38. inner join tender_master t on ( d.cd_dealer = t.cd_dealer_p and t.cd_sale = '$cd_sale' and t.ds_delind='N' )
  39. inner join sale_master s on t.cd_sale = s.cd_sale and s.cd_sale = $cd_sale AND s.ds_delind='N'
  40. $add_sql
  41. ";
  42. // echo $sql;
  43. // echo "select count(*) FROM ucaro_master d inner join tender_master t on (d.cd_dealer = t.cd_dealer_p and t.cd_sale = $cd_sale and t.ds_delind='N' $sql)";
  44. $totalrows = @mysql_result(mysql_query($sql),0,0);
  45. ?>
  46. <!-- 업체 리스트 -->
  47. <section>
  48. <div class="data--table--wrap mt-5">
  49. <div class="col-12 title--wrapper d-flex align-items-center justify-content-between">
  50. <h2><a name="tender_list"><?=$tender_list_title?> 리스트</a></h2>
  51. <div class="col-md-6 d-flex justify-content-end">
  52. <div>
  53. <select id="inputState" class="form-select" style="width:100px;">
  54. <option selected="">최근순</option>
  55. <option></option>
  56. </select>
  57. </div>
  58. </div>
  59. </div>
  60. <table class="table table-bordered mt-3">
  61. <colgroup>
  62. <col style="width:10%;">
  63. <col style="width:90%;">
  64. </colgroup>
  65. <thead>
  66. <tr>
  67. <th>
  68. <div class="d-flex justify-content-center">NO</div>
  69. </th>
  70. <th>
  71. <div class="d-flex justify-content-center">입찰금액</div>
  72. </th>
  73. </tr>
  74. </thead>
  75. <tbody>
  76. <?php
  77. if($totalrows>0) {
  78. $sql = "SELECT t.*, d.nm_name nm_name_dealer, d.nm_name nm_name_dealer, s.ds_status ds_status_sale
  79. , getRemainTimeByPhase(s.ds_auction_time, ".LIMIT_TIME_SELL.", s.dt_approve, now()) as time_limit_sell
  80. , d1.nm_name nm_name_dealer1
  81. , d1.nm_hp nm_hp_dealer1
  82. , s.nm_price_final
  83. FROM aap_master d
  84. inner join tender_master t on (d.cd_dealer = t.cd_dealer_p and t.cd_sale = '$cd_sale' and t.ds_delind='N')
  85. inner join aap_master d1 on (t.cd_dealer = d1.cd_dealer)
  86. inner join sale_master s on (t.cd_sale = s.cd_sale)
  87. $add_sql
  88. $sOrderBy
  89. LIMIT $pagestartpoint,$PageSize";
  90. // echo $sql;
  91. // exit;
  92. $r = mysql_query($sql);
  93. $i=1;
  94. $status_bid_success = array('Z0', 'ZS', 'ZE');
  95. $status_bid_fail = array('E0', 'F0');
  96. while($col = mysql_fetch_array($r)) {
  97. $tmpNum =$totalrows-($PageSize*($PageNo-1));
  98. $aapNum = ($tmpNum - $i)+1;
  99. ?>
  100. <tr>
  101. <td>
  102. <div class="d-flex justify-content-center"><?=$aapNum?></div>
  103. </td>
  104. <td>
  105. <div class="d-flex align-items-center justify-content-center">
  106. <input type="text" class="form-control" style="max-width:200px" value="<?=number_format($col['nm_ex_vat_price'])?>" />
  107. <label class="ms-3">만원</label>
  108. <?php
  109. $btn_bid_proc = "";
  110. //낙찰이후 상태
  111. if(in_array($col['ds_status_sale'], $status_bid_success)) {
  112. if($col['ds_status_sale'] == "ZE"){
  113. $status_text = '거래실수';
  114. }else {
  115. if($col['ds_status'] == "Z0") {
  116. $status_text = '낙찰';
  117. }else {
  118. $status_text = '낙첨';
  119. }
  120. }
  121. }else {
  122. if(in_array($col['ds_status_sale'], $status_bid_fail)) {
  123. if($col['time_limit_sell']=="0분"){
  124. $status_text = '낙첨';
  125. }
  126. else {
  127. $status_text = '입찰중';
  128. $btn_bid_proc = "<button type='button' class='btn btn-primary ms-3 btn_bid_proc' cd_tender='{$col['cd_tender']}' nm_name_dealer='{$col['nm_name_dealer']}' nm_price='{$col['nm_price']}' value='{$col['cd_tender']}' >낙찰하기</button>";
  129. //<button class="button button_s_rnd ty2" type='button' onclick="selectTender('{$col['cd_tender']}','{$col['nm_name_dealer1'}','{$col['nm_price'}')" >판매완료</button>
  130. }
  131. }
  132. }
  133. ?>
  134. <?//$status_text?>
  135. <?=$btn_bid_proc?>
  136. <?/*<button class="button button_s_rnd ty2" type='button' onclick="selectTender('<?=$col[cd_tender]?>','<?=$col[nm_name_dealer1]?>','<?=$col[nm_price]?>')" >판매완료</button>*/?>
  137. </div>
  138. </td>
  139. </tr>
  140. <?php
  141. $i++;
  142. }
  143. }else{
  144. ?>
  145. <tr>
  146. <td colspan="6" align="center">데이터가 존재 하지 않습니다.</td>
  147. </tr>
  148. <?php
  149. }
  150. ?>
  151. </tbody>
  152. </table>
  153. </div>
  154. <div class="col-12 d-flex justify-content-center pagination--wrapper">
  155. <?php
  156. $url = "./$list_url?searchtype=$searchtype&searchword=$searchword&ds_status=$ds_status&ds_usertype=$ds_usertype&PageSort=$PageSort";
  157. ListPg($url ,$PageNo,$PageSize,10,$totalrows,$leftboard[1],$rootpath);
  158. ?>
  159. </div>
  160. <!-- <div class="btn--wrapper col-12 d-flex justify-content-center mt-5">
  161. <button type="button" class="btn btn-secondary list--btn" style="width:190px; height:65px;">목록</button>
  162. </div> -->
  163. </section>
  164. <form name="frmTenderForm" id="frmTenderForm" method="post" action="sale_proc.php">
  165. <input type="hidden" name="mode" value="TenderSuccessAAP">
  166. <input type="hidden" name="cd_sale" value="<?=$cd_sale?>">
  167. <input type="hidden" name="cd_tender" >
  168. <input type="hidden" name="nm_price" >
  169. </form>
  170. <script>
  171. $(function() {
  172. $(".btn_bid_proc").on("click", function() {
  173. var custom_opts = {
  174. title : '',
  175. btn_close_show : false,
  176. }
  177. var cd_tender = $(this).val();
  178. var nm_price = $(this).attr("nm_price");
  179. var nm_name_dealer = $(this).attr("nm_name_dealer");
  180. custom_opts.title = '입찰업체를 낙찰하시겠습니까?';
  181. custom_modal_confirm(custom_opts, function(confirm) {
  182. if(confirm) {
  183. $("#frmTenderForm input[name=cd_tender]").val(cd_tender);
  184. $("#frmTenderForm input[name=nm_price]").val(nm_price);
  185. $("#btn_bid_proc").hide();
  186. var data = $("#frmTenderForm").serialize();
  187. $.ajax({
  188. url : 'sale_proc.php',
  189. type: 'POST',
  190. dataType : 'json',
  191. data: data,
  192. success: function(res) {
  193. custom_modal_confirm_close();
  194. $("#btn_bid_proc").show();
  195. //세션 종료시 로그인 페이지로 이동
  196. if(res.CODE != "0000") {
  197. custom_opts.title = res.MSG;
  198. if(res.CODE == "4444") {
  199. window.location.href = res.DATAS.URL;
  200. }
  201. custom_modal_alert(custom_opts);
  202. return false;
  203. }
  204. custom_opts.title = '낙찰되었습니다.';
  205. custom_opts.event_esc_key = false;
  206. custom_modal_alert(custom_opts, function() {
  207. reload();
  208. });
  209. },
  210. error:function(request,status,error){
  211. $("#btn_bid_proc").show();
  212. custom_modal_confirm_close();
  213. alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
  214. }
  215. });
  216. }else {
  217. $("#btn_bid_proc").show();
  218. return false;
  219. }
  220. });
  221. });
  222. })
  223. </script>