brand_form.php 5.9 KB

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