model_form.php 6.6 KB

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