sell_step4.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <?php
  2. include $_SERVER['DOCUMENT_ROOT'].'/common/lib/comm.php';
  3. include $_SERVER['DOCUMENT_ROOT'].'/common/auth_chk_m.php';
  4. $nav_title = "차량 판매 > 추가 사진 정보 입력";
  5. $HEADER_LOC = 'main';
  6. $mode = $_REQUEST['mode'];
  7. $s_cd_sale = $_SESSION['s_cd_sale'];
  8. $s_cd_car = $_SESSION['s_cd_car'];
  9. $ds_cate = $_REQUEST['ds_cate'];
  10. // Auth -> Step 단계에 따른 정상적인 요청 체크
  11. if($mode != "Step4" || $mode == null)
  12. AlertBack("지정되지 않은 요청입니다.");
  13. if(!$ds_cate) $ds_cate='A0';
  14. $ds_model_cate= $ds_cate;
  15. $add_img = array();
  16. if($s_cd_car !="" || $s_cd_car != null){
  17. $sql ="SELECT a.*, s.nm_recommend
  18. FROM car_master a left outer join sale_master s on ( a.cd_car = s.cd_car )
  19. WHERE a.cd_car='$s_cd_car' AND a.ds_delind='N'";
  20. $col=mysql_fetch_array(mysql_query($sql));
  21. if (!empty($col['cd_car'])){
  22. $cd_car = $col['cd_car'];
  23. $upload_file_main_name = $col['nm_file_main'];
  24. $upload_file_list_name = $col['nm_file_list'];
  25. $nm_file_front = $col['nm_file_front'];
  26. $nm_file_back = $col['nm_file_back'];
  27. $nm_file_side1 = $col['nm_file_side1'];
  28. $nm_file_side2 = $col['nm_file_side2'];
  29. $nm_file_dashboard = $col['nm_file_dashboard'];
  30. $nm_recommend = $col['nm_recommend'];
  31. $r = mysql_query("SELECT * FROM car_file WHERE cd_car = '$cd_car' and ds_type='' and ds_delind='N' Order by no_sort asc , cd_car ASC ");
  32. $car_img_i=1;
  33. while($imgs = mysql_fetch_array($r)) {
  34. $add_img[] = UPLOAD_PATH_CAR.$imgs['cd_car']."_detail/".$imgs['nm_file'];
  35. }
  36. }else{
  37. AlertBack("게시물을 가져오지 못하였습니다.");
  38. }
  39. $PageNo = $PageNo;
  40. // $mode = "Update";
  41. }else{
  42. // $mode="Add";
  43. }
  44. if ($mode=="Add"){
  45. // $cd_userid = $_SESSION[admin_cd_userid];
  46. }
  47. if($ds_open==""){$ds_open="Y";}
  48. if($cd_category==""){$cd_category="1";}
  49. // 등록 중이던 Session s_cd_car 삭제하여 새로운 차량 등록하도록 한다.
  50. // $_SESSION['s_cd_sale'] = null;
  51. // $_SESSION['s_cd_car'] = null;
  52. ?>
  53. <?php include("../inc/inc_header.php"); ?>
  54. <main class="pb60">
  55. <section>
  56. <div class="sub--top--visual">
  57. <div class="contents--inner">
  58. <h2>차량 판매하기</h2>
  59. <p>이차조아에서는 사고 이력 조회 후 최고가 내차를 판매할 수 있습니다.</p>
  60. </div>
  61. </div>
  62. </section>
  63. <section class="mt35">
  64. <form id="frmForm" name="frmForm" method="post" action="proc.php" enctype="multipart/form-data">
  65. <input type="hidden" name="mode" id="mode" value="<?=$mode?>"/>
  66. <div class="options--wrapper">
  67. <h2>사진 입력<span class="astc--text ty2">(추가 사진)</span></h2>
  68. <div class="pic--add--wrap">
  69. <?php
  70. for($i=0, $j=1; $i < 5; $i++, $j++) {
  71. $tmp_add_img = "";
  72. if(!empty($add_img[$i])) {
  73. $tmp_add_img = "background-image:url('".$add_img[$i]."');";
  74. }
  75. ?>
  76. <div class="add--box addition--box">
  77. <div class="thumb--wrap">
  78. <div class="thumb"></div>
  79. </div>
  80. <div class="desc">
  81. <input type="file" hidden name="upload_file[<?=$i?>]" id="nm_file_0<?=$j?>" class="upload-hidden" onchange="viewThumb(<?=$i?>,this)" accept="image/*">
  82. <label class="add--btn" for="nm_file_0<?=$j?>">사진 등록</label>
  83. </div>
  84. </div>
  85. <?php } ?>
  86. </div>
  87. </div>
  88. </section>
  89. <div class="btn--wrapper car--btn--wrapper floating--btn">
  90. <button type='button' id='btn_write' class="next--btn">다음(차량 설명)<i class="next--ic"></i></button>
  91. </div>
  92. <!-- loading -->
  93. <div class="loading_wrap hide">
  94. <?php include("../../include/loading_dim.html") ?>
  95. </div>
  96. <!-- // loading -->
  97. </main>
  98. <script>
  99. function form_data(){
  100. var sdata = new FormData();
  101. $("#frmForm input, #frmForm select, #frmForm textarea").each(function(idx, item){
  102. var _inputName = $(this).attr("name");
  103. var _inputVale = $(this).val();
  104. var _inputType = $(this).attr("type");
  105. if(_inputType == "radio" || _inputType == "checkbox"){
  106. console.log(_inputName);
  107. console.log(_inputVale);
  108. _inputVale = $("[name="+_inputName+"]:checked").val();
  109. if($(this).prop("checked")){
  110. sdata.append(_inputName, _inputVale);
  111. }
  112. }else{
  113. sdata.append(_inputName, _inputVale);
  114. }
  115. });
  116. $("#frmForm input[type=file]").each(function() {
  117. var input_name = $(this).attr("name");
  118. var input_value = $(this)[0].files[0];
  119. sdata.append(input_name, input_value);
  120. });
  121. return sdata;
  122. }
  123. function viewThumb(seq, arg){
  124. if($(arg).val() == "") {
  125. $(arg).closest("div.add--box").find(".thumb").css({"background":"#f7f7f9 url('/design/staff/assets/img/pic_ic.svg') no-repeat center"});
  126. }
  127. if (arg.files && arg.files[0])
  128. {
  129. var reader = new FileReader();
  130. reader.onload = function (e) {
  131. $(arg).closest("div.add--box").find(".thumb").css({"background":"url('"+e.target.result+"') no-repeat center"});
  132. }
  133. reader.readAsDataURL(arg.files[0]);
  134. }
  135. }
  136. $(document).ready(function() {
  137. $("#btn_write").bind("click",function(){
  138. var custom_opts = {
  139. title : '',
  140. btn_close_show : false,
  141. }
  142. var uploaded_cnt = <?=count($add_img)?>;
  143. $("input[type=file]").each(function() {
  144. if($(this).val()) {
  145. uploaded_cnt++;
  146. };
  147. });
  148. if(uploaded_cnt == 0) {
  149. custom_opts.title = '추가 사진을 등록하지 않고 정보를 등록하시겠습니까?';
  150. }else {
  151. custom_opts.title = '정보를 등록하시겠습니까?';
  152. }
  153. custom_modal_confirm(custom_opts, function(confirm) {
  154. if(confirm) {
  155. custom_modal_confirm_close();
  156. $(".loading_wrap").removeClass("hide");
  157. // $("#frmForm").submit();
  158. $("#btn_write").hide();
  159. var data = form_data();
  160. $.ajax({
  161. url : 'proc.php',
  162. type: 'POST',
  163. dataType : 'json',
  164. data: data,
  165. processData: false,
  166. contentType: false,
  167. success: function(res) {
  168. $("#btn_write").show();
  169. custom_modal_confirm_close();
  170. $(".loading_wrap").addClass("hide");
  171. if(res.CODE != "0000") {
  172. //세션이 없어지면 내차 팔기 초기 화면으로 이동
  173. if(res.CODE == "8888") {
  174. alert(res.MSG);
  175. window.location.replace(res.DATAS.URL);
  176. return false;
  177. }
  178. custom_opts.title = res.MSG;
  179. custom_modal_alert(custom_opts);
  180. return false;
  181. }
  182. link("sell_step5.php?mode=Step5");
  183. // window.location.href = res.DATAS.URL;
  184. return false;
  185. },
  186. error:function(request,status,error){
  187. $(".loading_wrap").addClass("hide");
  188. $("#btn_write").show();
  189. custom_modal_confirm_close();
  190. alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
  191. }
  192. });
  193. }else {
  194. $("#btn_write").show();
  195. return false;
  196. }
  197. });
  198. });
  199. });
  200. </script>
  201. <?php include("../inc/inc_bottom.php"); ?>
  202. <?php
  203. mysql_close($connect);
  204. ?>