grade_form.php 8.2 KB

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