model_sub_form.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <?php
  2. include $_SERVER['DOCUMENT_ROOT'].'/common/lib/comm.php';
  3. include $_SERVER['DOCUMENT_ROOT'].ADMIN_PATH.'common/auth_chk.php';
  4. $cd_model_sub = $_REQUEST['cd_model_sub'];
  5. $mp = "12"; //set top nav
  6. /*$ds_cate = $_REQUEST[ds_cate];
  7. if(!$ds_cate) $ds_cate='A0';
  8. */
  9. if($cd_model_sub!="" || $cd_model_sub!=null){
  10. $sql ="SELECT
  11. mst.*
  12. ,(select cd_category from car_model sub where sub.cd_model = mst.cd_model) cd_category
  13. ,(select cd_brand from car_model sub where sub.cd_model = mst.cd_model) cd_brand
  14. FROM car_model_sub mst
  15. WHERE cd_model_sub='$cd_model_sub' AND ds_delind='N'";
  16. $col=mysql_fetch_array(mysql_query($sql));
  17. if (!empty($col['cd_model_sub'])){
  18. $cd_category =$col["cd_category"];
  19. $cd_brand =$col["cd_brand"];
  20. $cd_model_sub =$col["cd_model_sub"];
  21. $cd_model =$col["cd_model"];
  22. $nm_model_sub =$col["nm_model_sub"];
  23. $ds_status =$col["ds_status"];
  24. $mode ="Update";
  25. }else{
  26. AlertBack("게시물을 가져오지 못하였습니다.");
  27. }
  28. $PageNo = $PageNo;
  29. }else{
  30. $mode="Add";
  31. }
  32. if ($mode=="Add"){
  33. $cd_userid = $_SESSION['admin_cd_userid'];
  34. }
  35. if($ds_open==""){$ds_open="Y";}
  36. ?>
  37. <? include("../inc/inc_top.php") ?>
  38. <? include("../inc/inc_header.php") ?>
  39. <section id="contents">
  40. <!-- 세부모델 -->
  41. <h2>세부모델</h2>
  42. <form id="frmForm" name="frmForm" method="post" action="model_sub_proc.php" enctype="multipart/form-data">
  43. <input type="hidden" name="mode" id="mode" value="<?=$mode?>"/>
  44. <input type="hidden" name="cd_userid" id="cd_userid" value="<?=$cd_userid?>"/>
  45. <input type="hidden" name="ds_status" id="ds_status" value="<?=$ds_status?>"/>
  46. <input type="hidden" name="cd_model_sub" id="cd_model_sub" value="<?=$cd_model_sub?>"/>
  47. <input type="hidden" name="ds_cate" id="ds_cate" value="<?=$ds_cate?>"/>
  48. <input type="hidden" name="PageNo" id="PageNo" value="<?=$PageNo?>"/>
  49. <div class="tbl_wrap">
  50. <table class="tbl_list2 ty2">
  51. <colgroup>
  52. <col width="20%">
  53. <col width="*">
  54. </colgroup>
  55. <tr>
  56. <th>구분</th>
  57. <td>
  58. <span class="select" style="width:200px;" id="sel_cd_category">
  59. <select name="cd_category" id="cd_category" onchange="cd_category_chg(this.value)">
  60. </span>
  61. </td>
  62. </tr>
  63. <tr>
  64. <th>제조사</th>
  65. <td>
  66. <span class="select" style="width:200px;" id="sel_cd_brand">
  67. <select id="cd_brand" name="cd_brand" onchange="cd_brand_chg(this.value)"></select>
  68. </span>
  69. </td>
  70. </tr>
  71. <tr>
  72. <th>모델</th>
  73. <td>
  74. <span class="select" style="width:200px;" id="sel_cd_model">
  75. <select id="cd_model" name="cd_model"></select>
  76. </span>
  77. </td>
  78. </tr>
  79. <tr>
  80. <th>세부모델</th>
  81. <td><input type="text" class="inp_txt" style="width:60%;" name="nm_model_sub" id="nm_model_sub" value="<?=$nm_model_sub?>"></td>
  82. </tr>
  83. </table>
  84. </div>
  85. </form>
  86. <div class="btn_right">
  87. <? if($mode=="Add"){?>
  88. <a href="#" class="rnd_btn ty2 black" id="btn_write">등록</a>
  89. <?}elseif($mode=="Update"){?>
  90. <a href="#" class="rnd_btn ty2 black" id="btn_write">수정</a>
  91. <a href="#" class="rnd_btn ty2 black" onclick="fnDelete('<?=$cd_model_sub?>');">삭제</a>
  92. <?}?>
  93. <a href="#" class="rnd_btn ty2 black" onclick="fnList();return false;">목록</a>
  94. </div>
  95. </section>
  96. <form id="delFrm" name="delFrm" method="post" action="./model_sub_proc.php">
  97. <input type="hidden" name="mode" id="mode" value="Delete"/>
  98. <input type="hidden" name="cd_model_sub" id="cd_model_sub_del"/>
  99. <input type="hidden" name="ds_cate" value="<?=$ds_cate?>"/>
  100. </form>
  101. <script language="javascript" type="text/javascript">
  102. var ds_mode ="<?=$mode?>";
  103. function fnList(model_sub, cate){
  104. location.replace("./model_sub.php?cd_model_sub="+model_sub+"&ds_cate="+cate);
  105. }
  106. function fnDelete(cd_model_sub){
  107. $("#cd_model_sub_del").val(cd_model_sub);
  108. var custom_opts = {
  109. title : '정말로 삭제 하시겠습니까?',
  110. btn_close_show : false,
  111. }
  112. custom_modal_confirm(custom_opts, function(confirm) {
  113. if(confirm) {
  114. $("#btn_delete").hide();
  115. var data = $("#delFrm").serialize();
  116. $.ajax({
  117. url : 'model_sub_proc.php',
  118. type: 'POST',
  119. dataType : 'json',
  120. data: data,
  121. success: function(res) {
  122. custom_modal_confirm_close();
  123. $("#btn_delete").show();
  124. //세션 종료시 로그인 페이지로 이동
  125. if(res.CODE != "0000") {
  126. custom_opts.title = res.MSG;
  127. if(res.CODE == "4444") {
  128. window.location.href = res.DATAS.URL;
  129. }
  130. custom_modal_alert(custom_opts);
  131. return false;
  132. }
  133. custom_opts.title = '삭제 되었습니다.';
  134. custom_opts.event_esc_key = false;
  135. custom_modal_alert(custom_opts, function() {
  136. link("<?=ADMIN_PATH?>/car/model_sub.php");
  137. });
  138. },
  139. error:function(request,status,error){
  140. $("#btn_delete").show();
  141. custom_modal_confirm_close();
  142. alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
  143. }
  144. });
  145. }else {
  146. $("#btn_delete").show();
  147. return false;
  148. }
  149. });
  150. }
  151. function cd_category_chg(val) {
  152. setCodeSelectJqTransForm("listBrandBycate","cd_brand","car_brand","cd_brand",'','선택하세요',val);
  153. }
  154. function cd_brand_chg(val) {
  155. setCodeSelectJqTransForm("listModelBybrand","cd_model","car_model","cd_model","",'선택하세요',val);
  156. }
  157. $(document).ready(function() {
  158. setCodeSelectJqTransForm("listcategory","cd_category", "car_category","cd_category","<?=$cd_category?>","선택하세요","");
  159. setCodeSelectJqTransForm("listBrandBycate","cd_brand","car_brand","cd_brand",'<?=$cd_brand?>','선택하세요','<?=$cd_category?>');
  160. setCodeSelectJqTransForm("listModelBybrand","cd_model","car_model","cd_model",'<?=$cd_model?>','선택하세요','<?=$cd_brand?>');
  161. // $("#cd_category").change(function(){
  162. // setCodeSelect("listBrandBycate","cd_brand","car_brand","cd_brand","",'선택하세요',$(this).val());
  163. // });
  164. //
  165. // $("#cd_brand").change(function(){
  166. // setCodeSelect("listModelBybrand","cd_model","car_model","cd_model","",'선택하세요',$(this).val());
  167. // });
  168. // $("#ds_sel_cate").change(function(){
  169. // var va = $(this).val();
  170. // setCodeSelect("listModel","cd_model","car_model","cd_model","<?=$cd_model?>",'선택하세요',va);
  171. //
  172. // });
  173. // setCodeSelect("listModel","cd_model","car_model","cd_model","<?=$cd_model?>",'선택하세요',"A0");
  174. $("#btn_write").bind("click",function(){
  175. var fieldlist = [["cd_category", "구분"],["cd_brand", "제조사"],["cd_model","모델"],["nm_model_sub","세부모델"]]
  176. if (!fnCheckForm(fieldlist)){
  177. return false;
  178. }
  179. var custom_opts = {
  180. title : '',
  181. btn_close_show : false,
  182. }
  183. var mode = "<?=$mode?>";
  184. if(mode == "Update") {
  185. custom_opts.title = '정보를 수정하시겠습니까?';
  186. }else {
  187. custom_opts.title = '정보를 등록하시겠습니까?';
  188. }
  189. custom_modal_confirm(custom_opts, function(confirm) {
  190. if(confirm) {
  191. $("#btn_write").hide();
  192. var data = $("#frmForm").serialize();
  193. $.ajax({
  194. url : 'model_sub_proc.php',
  195. type: 'POST',
  196. dataType : 'json',
  197. data: data,
  198. success: function(res) {
  199. custom_modal_confirm_close();
  200. $("#btn_write").show();
  201. //세션 종료시 로그인 페이지로 이동
  202. if(res.CODE != "0000") {
  203. custom_opts.title = res.MSG;
  204. if(res.CODE == "4444") {
  205. window.location.href = res.DATAS.URL;
  206. }
  207. custom_modal_alert(custom_opts);
  208. return false;
  209. }
  210. if(mode == "Update") {
  211. custom_opts.title = '수정이 완료되었습니다.';
  212. }else {
  213. custom_opts.title = '등록이 완료되었습니다.';
  214. }
  215. custom_opts.event_esc_key = false;
  216. custom_modal_alert(custom_opts, function() {
  217. reload();
  218. });
  219. },
  220. error:function(request,status,error){
  221. $("#btn_write").show();
  222. custom_modal_confirm_close();
  223. alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
  224. }
  225. });
  226. }else {
  227. $("#btn_write").show();
  228. return false;
  229. }
  230. });
  231. });
  232. });
  233. </script>
  234. <? include("../inc/inc_footer.php") ?>
  235. <? include("../inc/inc_bottom.php") ?>
  236. <?
  237. mysql_close($connect);
  238. ?>