manager_form.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. <?php
  2. include $_SERVER['DOCUMENT_ROOT'].'/common/lib/comm.php';
  3. include $_SERVER['DOCUMENT_ROOT'].'/common/aap_chk_m.php';
  4. $HEADER_LOC = 'main';
  5. $nav_title = "관리자 관리";
  6. $cd_dealerid = $_REQUEST["cd_dealerid"];
  7. $ds_type = "D1";
  8. $sql ="SELECT
  9. *
  10. FROM aap_master
  11. WHERE cd_dealerid='$cd_dealerid' AND ds_type = 'D1' AND ds_delind='N'";
  12. // echo $sql;
  13. $mode = "Add";
  14. $ds_usertype = $_SESSION['s_ds_usertype'];
  15. $ds_company_bp1 = $_SESSION['s_ds_company_bp1'];
  16. $ds_branch1 = $_SESSION['s_ds_branch1'];
  17. $ds_company_bp2 = $_SESSION['s_ds_company_bp2'];
  18. $ds_branch2 = $_SESSION['s_ds_branch2'];
  19. $ds_company_bp3 = $_SESSION['s_ds_company_bp3'];
  20. $ds_branch3 = $_SESSION['s_ds_branch3'];
  21. $col=mysql_fetch_array(mysql_query($sql));
  22. if (!empty($col['cd_dealer'])){
  23. $cd_dealer = $col['cd_dealer'];
  24. $cd_dealerid = $col['cd_dealerid'];
  25. $cd_dealer_p = $col['cd_dealer_p'];
  26. $nm_pass = $col['nm_pass'];
  27. $ds_type = $col['ds_type'];
  28. $ds_usertype = $col['ds_usertype'];
  29. $ds_level = $col['ds_level'];
  30. $nm_company = $col['nm_company'];
  31. $nm_name = $col['nm_name'];
  32. $nm_birth = $col['nm_birth'];
  33. $nm_tel_01 = $col['nm_tel_01'];
  34. $nm_tel_02 = $col['nm_tel_02'];
  35. $nm_tel_03 = $col['nm_tel_03'];
  36. $nm_hp1 = $col['nm_hp_01'];
  37. $nm_hp2 = $col['nm_hp_02'];
  38. $nm_hp3 = $col['nm_hp_03'];
  39. $nm_fax_01 = $col['nm_fax_01'];
  40. $nm_fax_02 = $col['nm_fax_02'];
  41. $nm_fax_03 = $col['nm_fax_03'];
  42. $nm_email = $col['nm_email'];
  43. $nm_zip = $col['nm_zip'];
  44. $nm_addr = $col['nm_addr'];
  45. $nm_addr_sub = $col['nm_addr_sub'];
  46. $nm_etc_01 = $col['nm_etc_01'];
  47. $nm_etc_02 = $col['nm_etc_02'];
  48. $nm_etc_03 = $col['nm_etc_03'];
  49. $ds_status = $col['ds_status'];
  50. $nm_company_biz = $col['nm_company_biz'];
  51. $nm_name_biz = $col['nm_name_biz'];
  52. $nm_no_biz = $col['nm_no_biz'];
  53. $nm_date_biz = $col['nm_date_biz'];
  54. $nm_type_biz = $col['nm_type_biz'];
  55. $nm_condition_biz = $col['nm_condition_biz'];
  56. $nm_tel_biz_01 = $col['nm_tel_biz_01'];
  57. $nm_tel_biz_02 = $col['nm_tel_biz_02'];
  58. $nm_tel_biz_03 = $col['nm_tel_biz_03'];
  59. $nm_hp_biz_01 = $col['nm_hp_biz_01'];
  60. $nm_hp_biz_02 = $col['nm_hp_biz_02'];
  61. $nm_hp_biz_03 = $col['nm_hp_biz_03'];
  62. $nm_fax_biz_01 = $col['nm_fax_biz_01'];
  63. $nm_fax_biz_02 = $col['nm_fax_biz_02'];
  64. $nm_fax_biz_03 = $col['nm_fax_biz_03'];
  65. $nm_email_biz = $col['nm_email_biz'];
  66. $nm_zip_biz = $col['nm_zip_biz'];
  67. $nm_addr_biz = $col['nm_addr_biz'];
  68. $nm_addr_sub_biz = $col['nm_addr_sub_biz'];
  69. $ds_company_bp1 = $col['ds_company_bp1'];
  70. $ds_branch1 = $col['ds_branch1'];
  71. $ds_company_bp2 = $col['ds_company_bp2'];
  72. $ds_branch2 = $col['ds_branch2'];
  73. $ds_company_bp3 = $col['ds_company_bp3'];
  74. $ds_branch3 = $col['ds_branch3'];
  75. $nm_area = $col['nm_area'];
  76. $nm_title = $col['nm_title'];
  77. $nm_file = $col['nm_file'];
  78. $nm_etc = $col['nm_etc'];
  79. $nm_deposit = $col['nm_deposit'];
  80. $dt_insert = $col['dt_insert'];
  81. $nm_insert = $col['nm_insert'];
  82. $dt_update = $col['dt_update'];
  83. $nm_update = $col['nm_update'];
  84. $ds_delind = $col['ds_delind'];
  85. /*
  86. $arr_nm_info1 = explode("-",$nm_info1);
  87. if(count($arr_nm_info1) == 3){
  88. $nm_info11 = $arr_nm_info1['0'];
  89. $nm_info12 = $arr_nm_info1['1'];
  90. $nm_info13 = $arr_nm_info1['2'];
  91. }else{
  92. $nm_info11 = "";
  93. $nm_info12 = "";
  94. $nm_info13 = "";
  95. }
  96. $arr_nm_info3 = explode("@",$nm_info3);
  97. if(count($arr_nm_info3) == 2){
  98. $nm_info31 = $arr_nm_info3['0'];
  99. $nm_info32 = $arr_nm_info3['1'];
  100. }else{
  101. $nm_info31 = "";
  102. $nm_info32 = "";
  103. }
  104. $nm_info3 = $col['nm_info3'];
  105. */
  106. $mode = "Update";
  107. $title_text = "수정";
  108. }else{
  109. $ds_level = "1";
  110. $title_text = "등록";
  111. }
  112. ?>
  113. <?php include("include/header.php") ?>
  114. <main class="pb123">
  115. <section>
  116. <div class="sub--top--visual">
  117. <div class="contents--inner">
  118. <h2>관리자 <?=$title_text?></h2>
  119. <p>이차조아에서는 사고 이력 조회 후 최고가 내차를 판매할 수 있습니다.</p>
  120. </div>
  121. </div>
  122. </section>
  123. <section>
  124. <div class="top--nav--wrap">
  125. <div class="contents--inner">
  126. <div class="breadcrumbs--wrap">
  127. <span></span>
  128. <span>관리자 관리</span>
  129. <span>관리자 <?=$title_text?></span>
  130. </div>
  131. </div>
  132. </div>
  133. </section>
  134. <section>
  135. <div class="car--info--wrap">
  136. <h2>관리자 <?=$title_text?></h2>
  137. <div class="form--wrap">
  138. <form id="frmMember" name="frmMember" method="post" action="manager_proc.php" enctype="multipart/form-data">
  139. <input type="hidden" name="validate" id="validate" value=""/>
  140. <input type="hidden" name="ds_type" id="ds_type" value="D1"/>
  141. <input type="hidden" name="ds_usertype" id="ds_usertype" value="<?=$ds_usertype?>"/>
  142. <input type="hidden" name="ds_company_bp1" id="ds_company_bp1" value="<?=$ds_company_bp1?>"/>
  143. <input type="hidden" name="ds_branch1" id="ds_branch1" value="<?=$ds_branch1?>"/>
  144. <input type="hidden" name="ds_company_bp2" id="ds_company_bp2" value="<?=$ds_company_bp2?>"/>
  145. <input type="hidden" name="ds_branch2" id="ds_branch2" value="<?=$ds_branch2?>"/>
  146. <input type="hidden" name="ds_company_bp3" id="ds_company_bp3" value="<?=$ds_company_bp3?>"/>
  147. <input type="hidden" name="ds_branch3" id="ds_branch3" value="<?=$ds_branch3?>"/>
  148. <input type="hidden" name="ds_level" id="ds_level" value="<?=$ds_level?>"/>
  149. <input type="hidden" name="cd_dealer" id="cd_dealer" value="<?=$cd_dealer?>"/>
  150. <input type="hidden" name="nm_hp" id="nm_hp" value="<?=$nm_hp?>"/>
  151. <input type="hidden" name="mode" id="mode" value="<?=$mode?>"/>
  152. <input type="hidden" name="PageNo" id="PageNo" value="<?=$PageNo?>"/>
  153. <?php if ($mode == "Add"){ ?>
  154. <input type="hidden" name="idchkresult" id="idchkresult" value="N"/>
  155. <?php }else{ ?>
  156. <input type="hidden" name="idchkresult" id="idchkresult" value="Y"/>
  157. <?php } ?>
  158. <div class="form--groups">
  159. <h2>아이디</h2>
  160. <div class="form--group d-flex align-items-center">
  161. <?php if ($mode == "Add"){ ?>
  162. <input type="text" class="" name="cd_dealerid" id="cd_dealerid" maxlength="20" value="<?=$cd_dealerid?>" >
  163. <label for="nm_file" class="ml10 btn btn-secondary d-flex align-items-center" style="height:43px;width: 146px;" id="btn_idchk">ID 중복확인</label>
  164. <!-- <p class="vaild--text mt-2">*사용가능한 아이디입니다.</p> -->
  165. <?php }else { ?>
  166. <input type="text" class="" name="cd_dealerid" id="cd_dealerid" maxlength="20" value="<?=$cd_dealerid?>" readonly>
  167. <?php } ?>
  168. </div>
  169. </div>
  170. <div class="form--groups mt-3">
  171. <h2>패스워드</h2>
  172. <div class="form--group">
  173. <input type="password" class="" style="" name="nm_pass" id="nm_pass" maxlength="20" />
  174. </div>
  175. </div>
  176. <?php if ($mode == "Add"){ ?>
  177. <div class="form--groups mt-3">
  178. <h2>패스워드 확인</h2>
  179. <div class="form--group">
  180. <input type="password" class="" style="" name="nm_pass2" id="nm_pass2" maxlength="20" />
  181. </div>
  182. </div>
  183. <?php } ?>
  184. <div class="form--groups">
  185. <h2>이름</h2>
  186. <div class="form--group">
  187. <input type="text" class="" style="" name="nm_name" id="nm_name" maxlength="20" value="<?=$nm_name?>" />
  188. </div>
  189. </div>
  190. <div class="form--groups">
  191. <h2>연락처</h2>
  192. <div class="form--group ty2">
  193. <select id="nm_hp1" name="nm_hp1">
  194. <option value="">선택</option>
  195. </select>
  196. <label for="" class="ml10">-</label>
  197. <input type="text" class="ml10" style="max-width:100px;" name="nm_hp2" id="nm_hp2" maxlength="4" value="<?=$nm_hp2?>" />
  198. <label for="" class="ml10">-</label>
  199. <input type="text" class="ml10" style="max-width:100px;" name="nm_hp3" id="nm_hp3" maxlength="4" value="<?=$nm_hp3?>" />
  200. </div>
  201. </div>
  202. <div class="form--groups">
  203. <h2>부서</h2>
  204. <div class="form--group">
  205. <input type="text" class="" style="" id="nm_title" name="nm_title" value="<?=$nm_title?>" />
  206. </div>
  207. </div>
  208. <div class="form--groups">
  209. <h2>사진(필수입력)</h2>
  210. <div class="form--group">
  211. <input type="file" id="nm_file" name="nm_file" class="" hidden style="" />
  212. <input type="text" id="upload-name" readonly value="<?=$nm_file?>">
  213. <label for="nm_file" class="btn btn-secondary mt-3 d-flex justify-content-center align-items-center" style="width:100%; height:55px;">찾아보기</label>
  214. </div>
  215. </div>
  216. </form>
  217. </div>
  218. </div>
  219. </section>
  220. </main>
  221. <div class="btn--wrapper col-12 d-flex justify-content-center floating--btn mt-5">
  222. <button type="button" class="btn btn-secondary" style="width:190px; height:65px;" id="btn_back">목록</button>
  223. <?php if($mode == "Update") { ?>
  224. <button type="button" class="btn btn-primary" style="width:190px; height:65px;" id="btn_write">정보수정</button>
  225. <button type="button" class="btn btn-secondary" style="width:180px; height:65px;" id="btn_delete">삭제</button>
  226. <?php } else {?>
  227. <button type="button" class="btn btn-primary" style="width:190px; height:65px;" id="btn_write">등록하기</button>
  228. <? } ?>
  229. </div>
  230. <script type="text/javascript">
  231. $(document).ready(function() {
  232. setCodeSelect("listPhone","nm_hp1","","","<?=$nm_hp1?>","선택","");
  233. $("#btn_back").on("click", function() {
  234. history.back(-1);
  235. })
  236. $("#cd_dealerid").bind("keyup",function(){
  237. $("#idchkresult").val("N");
  238. });
  239. $("#btn_idchk").bind("click",function(){
  240. var custom_opts = {
  241. title : '',
  242. btn_close_show : false,
  243. }
  244. var fieldlist = [["cd_dealerid","아이디"]]
  245. if (!fnCheckForm(fieldlist)){
  246. return false;
  247. }
  248. var idReg = /^[a-z]+[a-z0-9]{4,19}$/g;
  249. if( !idReg.test( $("#cd_dealerid").val() ) ) {
  250. custom_opts.title = '아이디는 영문자로 시작하는 5~20자 영문자 또는 숫자이어야 합니다.';
  251. custom_modal_alert(custom_opts);
  252. return false;
  253. }
  254. if(!fnCheckAlphaNumber($("#cd_dealerid").val())){
  255. custom_opts.title = '아이디는 영문/숫자 조합으로 이루어져야 합니다.';
  256. custom_modal_alert(custom_opts);
  257. return false;
  258. }
  259. if($("#cd_dealerid").val().length <5){
  260. custom_opts.title = '5글자 이상 아이디를 입력하세요.';
  261. custom_modal_alert(custom_opts);
  262. return false;
  263. }
  264. $.post("manager_proc.php", { mode: "IdChk", cd_dealerid: $("#cd_dealerid").val()},function(data) {
  265. if(data=="Y"){
  266. custom_opts.title = '이용가능합니다. 아이디를 사용하시겠습니까?';
  267. custom_modal_confirm(custom_opts, function(confirm) {
  268. if(confirm) {
  269. $("#cd_dealerid").attr("readonly",true).css("background","#d2d3d5");
  270. $("#idchkresult").val("Y");
  271. custom_modal_confirm_close();
  272. }
  273. });
  274. }else{
  275. $("#idchkresult").val("N");
  276. $("#cd_dealerid").attr("readonly",false).css("background","#fff");
  277. custom_opts.title = '사용불가능한 아이디 입니다.';
  278. custom_modal_alert(custom_opts);
  279. return false;
  280. }
  281. });
  282. return false;
  283. });
  284. $("#btn_delete").click(function() {
  285. var custom_opts = {
  286. title : '',
  287. btn_close_show : false,
  288. }
  289. custom_opts.title = '관리자를 삭제하시겠습니까?';
  290. custom_modal_confirm(custom_opts, function(confirm) {
  291. if(confirm) {
  292. $("#btn_delete").hide();
  293. var data = $("#frmMember").serialize();
  294. data+= "&mode=Delete";
  295. $.ajax({
  296. url : 'manager_proc.php',
  297. type: 'POST',
  298. dataType : 'json',
  299. data: data,
  300. success: function(res) {
  301. custom_modal_confirm_close();
  302. $("#btn_delete").show();
  303. //세션 종료시 로그인 페이지로 이동
  304. if(res.CODE != "0000") {
  305. custom_opts.title = res.MSG;
  306. if(res.CODE == "4444") {
  307. window.location.href = res.DATAS.URL;
  308. }
  309. custom_modal_alert(custom_opts);
  310. return false;
  311. }
  312. custom_opts.title = '관리자 삭제가 완료되었습니다.';
  313. custom_opts.event_esc_key = false;
  314. custom_modal_alert(custom_opts, function() {
  315. link("manager_list.php");
  316. });
  317. },
  318. error:function(request,status,error){
  319. $("#btn_delete").show();
  320. custom_modal_confirm_close();
  321. alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
  322. }
  323. });
  324. }else {
  325. $("#btn_delete").show();
  326. return false;
  327. }
  328. });
  329. });
  330. $("#btn_write").bind("click",function(){
  331. var custom_opts = {
  332. title : '',
  333. btn_close_show : false,
  334. }
  335. <? if ($mode == "Add"){ ?>
  336. var fieldlist = [["cd_dealerid","아이디"],["nm_pass","비밀번호"],["nm_pass2","비밀번호 확인"],["nm_name","이름"],["nm_hp1","핸드폰"],["nm_hp2","핸드폰"],["nm_hp3","핸드폰"]]
  337. //,["nm_file","사진"]
  338. <? }else{ ?>
  339. var fieldlist = [["nm_name","이름"],["nm_hp1","핸드폰"],["nm_hp2","핸드폰"],["nm_hp3","핸드폰"]]
  340. <? } ?>
  341. if (!fnCheckForm(fieldlist)){
  342. return false;
  343. }else{
  344. /*아이디 관련 처리*/
  345. <? if ($mode == "Add"){ ?>
  346. var idReg1 = /[a-z]/g;
  347. var idReg2 = /[0-9]/g;
  348. // if( !(idReg1.test( $("#cd_dealerid").val() )) || !(idReg2.test( $("#cd_dealerid").val() )) ) {
  349. // alert("아이디는 영문/숫자 조합으로 이루어져야 합니다.");
  350. // $("#cd_dealerid").focus();
  351. // return false;
  352. // }
  353. var idReg = /^[a-z]+[a-z0-9]{4,19}$/g;
  354. if( !idReg.test( $("#cd_dealerid").val() ) ) {
  355. custom_opts.title = '아이디는 영문자로 시작하는 5~20자 영문자 또는 숫자이어야 합니다.';
  356. custom_modal_alert(custom_opts);
  357. return false;
  358. }
  359. if(!fnCheckAlphaNumber($("#cd_dealerid").val())){
  360. custom_opts.title = '아이디는 영문/숫자 조합으로 이루어져야 합니다.';
  361. custom_modal_alert(custom_opts);
  362. return false;
  363. }
  364. if($("#cd_dealerid").val().length <5){
  365. custom_opts.title = '5글자 이상 아이디를 입력하세요.';
  366. custom_modal_alert(custom_opts);
  367. return false;
  368. }
  369. if($("#idchkresult").val() != "Y"){
  370. custom_opts.title = '아이디 중복확인을 해 주세요.';
  371. custom_modal_alert(custom_opts);
  372. return false;
  373. }
  374. if($("#nm_pass").val().length <8){
  375. custom_opts.title = '8글자 이상 패스워드를 입력하세요.';
  376. custom_modal_alert(custom_opts);
  377. return false;
  378. }
  379. var check = /^(?=.*[a-zA-Z])(?=.*[!@#$%^*+=-])(?=.*[0-9]).{6,16}$/;
  380. var nm_pass = $("#nm_pass").val();
  381. if (!check.test(nm_pass)) {
  382. custom_opts.title = "비밀번호는 문자, 숫자, 특수문자의 조합으로 입력해주세요.";
  383. custom_modal_alert(custom_opts);
  384. return false;
  385. }
  386. if (nm_pass.length < 6 || nm_pass.length > 16) {
  387. custom_opts.title = "비밀번호는 6 ~ 16 자리로 입력해주세요.";
  388. custom_modal_alert(custom_opts);
  389. return false;
  390. }
  391. //
  392. // if(!isStrongValidFormPassword($("#nm_pass").val())){
  393. // return false;
  394. // }
  395. <? } ?>
  396. if($("#nm_pass").val().length > 0){
  397. if($("#cd_dealerid").val()==$("#nm_pass").val()){
  398. custom_opts.title = '아이디와 변경할 패스워드를 다르게입력하세요.';
  399. custom_modal_alert(custom_opts);
  400. return false;
  401. }
  402. if($("#nm_pass").val().length <8){
  403. custom_opts.title = '8글자 이상 변경할 패스워드를 입력하세요.';
  404. custom_modal_alert(custom_opts);
  405. return false;
  406. }
  407. if(!isStrongValidFormPassword($("#nm_pass").val())){
  408. return false;
  409. }
  410. }
  411. var nm_hp = $("#nm_hp1").val()+"-"+$("#nm_hp2").val()+"-"+$("#nm_hp3").val();
  412. $("#nm_hp").val(nm_hp);
  413. custom_opts.title = '정보를 등록하시겠습니까?';
  414. custom_modal_confirm(custom_opts, function(confirm) {
  415. if(confirm) {
  416. $("#btn_write").hide();
  417. var data = $("#frmMember").serialize();
  418. var formData = new FormData();
  419. $("#frmMember input, #frmMember select").each(function() {
  420. var input_name = $(this).attr("name");
  421. var input_value = $(this).val();
  422. formData.append(input_name, input_value);
  423. });
  424. $("input[type=file]").each(function() {
  425. var input_name = $(this).attr("name");
  426. var input_value = $(this)[0].files[0];
  427. formData.append(input_name, input_value);
  428. });
  429. $.ajax({
  430. url : 'manager_proc.php',
  431. type: 'POST',
  432. dataType : 'json',
  433. data: formData,
  434. processData: false,
  435. contentType: false,
  436. success: function(res) {
  437. custom_modal_confirm_close();
  438. $("#btn_write").show();
  439. //세션 종료시 로그인 페이지로 이동
  440. if(res.CODE != "0000") {
  441. custom_opts.title = res.MSG;
  442. if(res.CODE == "4444") {
  443. window.location.href = res.DATAS.URL;
  444. }
  445. custom_modal_alert(custom_opts);
  446. return false;
  447. }
  448. custom_opts.title = '관리자 <?=$title_text?>이 완료되었습니다.';
  449. custom_opts.event_esc_key = false;
  450. custom_modal_alert(custom_opts, function() {
  451. reload();
  452. // link("manager_form.php");
  453. });
  454. },
  455. error:function(request,status,error){
  456. $("#btn_write").show();
  457. custom_modal_confirm_close();
  458. alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
  459. }
  460. });
  461. }else {
  462. $("#btn_write").show();
  463. return false;
  464. }
  465. });
  466. // fnCheckForm_ty10("정보를 등록하시겠습니까?");
  467. // var c=confirm("정보를 등록하시겠습니까?");
  468. // if(c){
  469. // $("#btn_write").hide();
  470. // $("#frmMember").submit();
  471. // }else{
  472. // $("#btn_write").show();
  473. // return false;
  474. // }
  475. }
  476. });
  477. $('#nm_file').on('change', function(){
  478. // 값이 변경되면
  479. if(window.FileReader){ // modern browser
  480. var filename = $(this)[0].files[0].name;
  481. } else {
  482. // old IE
  483. var filename = $(this).val().split('/').pop().split('\\').pop(); // 파일명만 추출
  484. } // 추출한 파일명 삽입
  485. $('#upload-name').val(filename);
  486. });
  487. });
  488. </script>
  489. <?php include("include/bottom.php") ?>