sell_step4.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <?php
  2. include $_SERVER['DOCUMENT_ROOT'].'/common/lib/comm.php';
  3. include $_SERVER['DOCUMENT_ROOT'].'/common/sa_chk_m.php';
  4. $HEADER_LOC = 'main';
  5. $nav_title = "차량판매하기 > STEP4";
  6. $mode = $_REQUEST['mode'];
  7. // Auth -> Step 단계에 따른 정상적인 요청 체크
  8. if($mode != "Step4" || $mode == null)
  9. AlertBack("지정되지 않은 요청입니다.");
  10. // $s_cd_sale = $_SESSION['s_cd_sale'];
  11. $s_staff_cd_car = $_SESSION['s_staff_cd_car'];
  12. $s_staff_car_update_ing = $_SESSION['s_staff_car_update_ing'];
  13. $ds_cate = $_REQUEST['ds_cate'];
  14. if(!$ds_cate) $ds_cate='A0';
  15. $ds_model_cate= $ds_cate;
  16. if($s_staff_cd_car !="" || $s_staff_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_staff_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. $add_img = array();
  34. while($imgs = mysql_fetch_array($r)) {
  35. $add_img[] = UPLOAD_PATH_CAR.$imgs['cd_car']."_detail/".$imgs['nm_file'];
  36. }
  37. }else{
  38. AlertBack("게시물을 가져오지 못하였습니다.");
  39. }
  40. $PageNo = $PageNo;
  41. // $mode = "Update";
  42. }else{
  43. // $mode="Add";
  44. }
  45. if ($mode=="Add"){
  46. // $cd_userid = $_SESSION[admin_cd_userid];
  47. }
  48. if($ds_open==""){$ds_open="Y";}
  49. if($cd_category==""){$cd_category="1";}
  50. // $s_cd_sale = $_SESSION['s_cd_sale'];
  51. $s_staff_cd_car = $_SESSION['s_staff_cd_car'];
  52. $ds_cate = $_REQUEST['ds_cate'];
  53. if(!$ds_cate) $ds_cate='A0';
  54. $ds_model_cate= $ds_cate;
  55. $add_file_sql = "SELECT * FROM car_file WHERE cd_car = '$col[cd_car]' and ds_delind='N' Order by no_sort asc, cd_car ASC ";
  56. $add_file_res = mysql_query($add_file_sql, $connect);
  57. $car_img_i=1;
  58. $add_img = array();
  59. while($imgs = mysql_fetch_array($add_file_res)) {
  60. $add_img[$imgs["no_sort"]] = UPLOAD_PATH_CAR.$imgs['cd_car']."_detail/".$imgs['nm_file'];
  61. }
  62. ?>
  63. <?php include("include/header.php") ?>
  64. <main class="pb60">
  65. <section>
  66. <div class="sub--top--visual">
  67. <div class="contents--inner">
  68. <h2>차량 판매하기</h2>
  69. <p>이차조아에서는 사고 이력 조회 후 최고가 내차를 판매할 수 있습니다.</p>
  70. </div>
  71. </div>
  72. </section>
  73. <section class="mt35">
  74. <form id="frmForm" name="frmForm" method="post" action="proc.php" enctype="multipart/form-data">
  75. <input type="hidden" name="mode" id="mode" value="<?=$mode?>"/>
  76. <div class="options--wrapper">
  77. <h2>사진 입력<span class="astc--text ty2">(추가 사진)</span></h2>
  78. <div class="pic--add--wrap">
  79. <?php
  80. for($i=0, $j=1; $i < 5; $i++, $j++) {
  81. $tmp_add_img_css = "";
  82. if(!empty($add_img[$i])) {
  83. $tmp_add_img_css = "background:url('".$add_img[$i]."') no-repeat center";
  84. }
  85. ?>
  86. <div class="add--box addition--box">
  87. <div class="thumb--wrap">
  88. <div class="thumb" style="<?=$tmp_add_img_css?>"></div>
  89. </div>
  90. <div class="desc">
  91. <input type="file" hidden name="upload_file[<?=$i?>]" id="nm_file_0<?=$j?>" class="upload-hidden" onchange="viewThumb(<?=$i?>,this)" accept="image/*">
  92. <label class="add--btn" for="nm_file_0<?=$j?>">사진 등록</label>
  93. </div>
  94. </div>
  95. <?php } ?>
  96. </div>
  97. </div>
  98. </section>
  99. <div class="btn--wrapper car--btn--wrapper floating--btn">
  100. <button type='button' id='btn_write' class="next--btn">다음(차량 설명)<i class="next--ic"></i></button>
  101. </div>
  102. <!-- loading -->
  103. <div class="loading_wrap hide">
  104. <?php include("../../include/loading_dim.html") ?>
  105. </div>
  106. <!-- // loading -->
  107. </main>
  108. <script>
  109. function form_data(){
  110. var sdata = new FormData();
  111. $("#frmForm input, #frmForm select, #frmForm textarea").each(function(idx, item){
  112. var _inputName = $(this).attr("name");
  113. var _inputVale = $(this).val();
  114. var _inputType = $(this).attr("type");
  115. if(_inputType == "radio" || _inputType == "checkbox"){
  116. console.log(_inputName);
  117. console.log(_inputVale);
  118. _inputVale = $("[name="+_inputName+"]:checked").val();
  119. if($(this).prop("checked")){
  120. sdata.append(_inputName, _inputVale);
  121. }
  122. }else{
  123. sdata.append(_inputName, _inputVale);
  124. }
  125. });
  126. $("#frmForm input[type=file]").each(function() {
  127. var input_name = $(this).attr("name");
  128. var input_value = $(this)[0].files[0];
  129. sdata.append(input_name, input_value);
  130. });
  131. return sdata;
  132. }
  133. function viewThumb(seq, arg){
  134. if($(arg).val() == "") {
  135. $(arg).closest("div.add--box").find(".thumb").css({"background":"#f7f7f9 url('/design/staff/assets/img/pic_ic.svg') no-repeat center"});
  136. }
  137. if (arg.files && arg.files[0])
  138. {
  139. var reader = new FileReader();
  140. reader.onload = function (e) {
  141. $(arg).closest("div.add--box").find(".thumb").css({"background":"url('"+e.target.result+"') no-repeat center"});
  142. }
  143. reader.readAsDataURL(arg.files[0]);
  144. }
  145. }
  146. $(document).ready(function() {
  147. $("#btn_write").bind("click",function(){
  148. var custom_opts = {
  149. title : '',
  150. btn_close_show : false,
  151. }
  152. var uploaded_cnt = <?=count($add_img)?>;
  153. $("input[type=file]").each(function() {
  154. if($(this).val()) {
  155. uploaded_cnt++;
  156. };
  157. });
  158. if(uploaded_cnt == 0) {
  159. custom_opts.title = '추가 사진을 등록하지 않고 정보를 등록하시겠습니까?';
  160. }else {
  161. custom_opts.title = '정보를 등록하시겠습니까?';
  162. }
  163. custom_modal_confirm(custom_opts, function(confirm) {
  164. if(confirm) {
  165. custom_modal_confirm_close();
  166. $(".loading_wrap").removeClass("hide");
  167. // $("#frmForm").submit();
  168. $("#btn_write").hide();
  169. var data = form_data();
  170. $.ajax({
  171. url : 'sell_proc.php',
  172. type: 'POST',
  173. dataType : 'json',
  174. data: data,
  175. processData: false,
  176. contentType: false,
  177. success: function(res) {
  178. $("#btn_write").show();
  179. custom_modal_confirm_close();
  180. $(".loading_wrap").addClass("hide");
  181. if(res.CODE != "0000") {
  182. //세션이 없어지면 내차 팔기 초기 화면으로 이동
  183. if(res.CODE == "8888") {
  184. alert(res.MSG);
  185. window.location.replace(res.DATAS.URL);
  186. return false;
  187. }
  188. custom_opts.title = res.MSG;
  189. custom_modal_alert(custom_opts);
  190. return false;
  191. }
  192. link("sell_step5.php?mode=Step5");
  193. // window.location.href = res.DATAS.URL;
  194. return false;
  195. },
  196. error:function(request,status,error){
  197. $(".loading_wrap").addClass("hide");
  198. $("#btn_write").show();
  199. custom_modal_confirm_close();
  200. alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
  201. }
  202. });
  203. // $("#btn_write").hide();
  204. // var formData = new FormData();
  205. // // lockLayer('loading');
  206. //
  207. // // confirm_l4(false, 'dconfirm');
  208. //
  209. // $("input[type=hidden]").each(function() {
  210. // var input_name = $(this).attr("name");
  211. // var input_value = $(this).val();
  212. // formData.append(input_name, input_value);
  213. // });
  214. // $("input[type=file]").each(function() {
  215. // var input_name = $(this).attr("name");
  216. // var input_value = $(this)[0].files[0];
  217. // formData.append(input_name, input_value);
  218. // });
  219. //
  220. // var url = "sell_proc.php";
  221. // $.ajax({
  222. // url: url,
  223. // type: 'post',
  224. // data: formData,
  225. // processData: false,
  226. // contentType: false,
  227. // success: function(res) {
  228. // custom_modal_confirm_close();
  229. //
  230. // $("#btn_write").show();
  231. //
  232. // res = $.parseJSON(res);
  233. //
  234. // // unlockLayer('loading');
  235. //
  236. // if(res.CODE != "0000"){
  237. // custom_opts.title = res.MSG;
  238. // custom_modal_alert(custom_opts);
  239. // return false;
  240. // // fnCheckForm_ty4(res.MSG);
  241. // }
  242. //
  243. // window.location.href = "sell_step4.php?mode=Step4";
  244. // },
  245. // error:function(request,status,error){
  246. // $("#btn_write").show();
  247. //
  248. // custom_modal_confirm_close();
  249. //
  250. // alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
  251. // }
  252. // });
  253. }else {
  254. $("#btn_write").show();
  255. return false;
  256. }
  257. });
  258. // fnCheckForm_ty7("정보를 등록하시겠습니까?");
  259. // var c = confirm("정보를 등록하시겠습니까?");
  260. // if(c){
  261. // $("#frmForm").submit();
  262. // file_save();
  263. // }else{
  264. // return false;
  265. // }
  266. });
  267. });
  268. </script>
  269. <?php include("include/bottom.php") ?>