<?php

	include $_SERVER["DOCUMENT_ROOT"].'/common/lib/comm.php';

	$table_name = "dealer_master";

	$PageNo = trim(avoid_crack($_REQUEST["PageNo"]));

	$mode = trim(avoid_crack($_POST["mode"]));

	$cd_dealer  = trim(avoid_crack($_POST["cd_dealer"]));
	$cd_dealerid  = trim(avoid_crack($_POST["cd_dealerid"]));
	$cd_dealer_p  = trim(avoid_crack($_POST["cd_dealer_p"]));
	$nm_pass  = trim(avoid_crack($_POST["nm_pass"]));
	$ds_type  = trim(avoid_crack($_POST["ds_type"]));
	$ds_level  = trim(avoid_crack($_POST["ds_level"]));
	$nm_company  = trim(avoid_crack($_POST["nm_company"]));
	$nm_name  = trim(avoid_crack($_POST["nm_name"]));
	$nm_birth  = trim(avoid_crack($_POST["nm_birth"]));
	$nm_tel_01  = trim(avoid_crack($_POST["nm_tel_01"]));
	$nm_tel_02  = trim(avoid_crack($_POST["nm_tel_02"]));
	$nm_tel_03  = trim(avoid_crack($_POST["nm_tel_03"]));
	$nm_hp_01  = trim(avoid_crack($_POST["nm_hp_01"]));
	$nm_hp_02  = trim(avoid_crack($_POST["nm_hp_02"]));
	$nm_hp_03  = trim(avoid_crack($_POST["nm_hp_03"]));
	$nm_fax_01  = trim(avoid_crack($_POST["nm_fax_01"]));
	$nm_fax_02  = trim(avoid_crack($_POST["nm_fax_02"]));
	$nm_fax_03  = trim(avoid_crack($_POST["nm_fax_03"]));
	$nm_email  = trim(avoid_crack($_POST["nm_email"]));
	$nm_zip  = trim(avoid_crack($_POST["nm_zip"]));
	$nm_addr  = trim(avoid_crack($_POST["nm_addr"]));
	$nm_addr_sub  = trim(avoid_crack($_POST["nm_addr_sub"]));
	$nm_etc_01  = trim(avoid_crack($_POST["nm_etc_01"]));
	$nm_etc_02  = trim(avoid_crack($_POST["nm_etc_02"]));
	$nm_etc_03  = trim(avoid_crack($_POST["nm_etc_03"]));
	$ds_status  = trim(avoid_crack($_POST["ds_status"]));
	$nm_company_biz  = trim(avoid_crack($_POST["nm_company_biz"]));
	$nm_name_biz  = trim(avoid_crack($_POST["nm_name_biz"]));
	$nm_no_biz  = trim(avoid_crack($_POST["nm_no_biz"]));
	$nm_date_biz  = trim(avoid_crack($_POST["nm_date_biz"]));
	$nm_type_biz  = trim(avoid_crack($_POST["nm_type_biz"]));
	$nm_condition_biz  = trim(avoid_crack($_POST["nm_condition_biz"]));
	$nm_tel_biz_01  = trim(avoid_crack($_POST["nm_tel_biz_01"]));
	$nm_tel_biz_02  = trim(avoid_crack($_POST["nm_tel_biz_02"]));
	$nm_tel_biz_03  = trim(avoid_crack($_POST["nm_tel_biz_03"]));
	$nm_hp_biz_01  = trim(avoid_crack($_POST["nm_hp_biz_01"]));
	$nm_hp_biz_02  = trim(avoid_crack($_POST["nm_hp_biz_02"]));
	$nm_hp_biz_03  = trim(avoid_crack($_POST["nm_hp_biz_03"]));
	$nm_fax_biz_01  = trim(avoid_crack($_POST["nm_fax_biz_01"]));
	$nm_fax_biz_02  = trim(avoid_crack($_POST["nm_fax_biz_02"]));
	$nm_fax_biz_03  = trim(avoid_crack($_POST["nm_fax_biz_03"]));
	$nm_email_biz  = trim(avoid_crack($_POST["nm_email_biz"]));
	$nm_zip_biz  = trim(avoid_crack($_POST["nm_zip_biz"]));
	$nm_addr_biz  = trim(avoid_crack($_POST["nm_addr_biz"]));
	$nm_addr_sub_biz  = trim(avoid_crack($_POST["nm_addr_sub_biz"]));
	$ds_company_bp1 = trim(avoid_crack($_POST["ds_company_bp1"]));
	$ds_branch1 = trim(avoid_crack($_POST["ds_branch1"]));
	$ds_company_bp2 = trim(avoid_crack($_POST["ds_company_bp2"]));
	$ds_branch2 = trim(avoid_crack($_POST["ds_branch2"]));
	$ds_company_bp3 = trim(avoid_crack($_POST["ds_company_bp3"]));
	$ds_branch3 = trim(avoid_crack($_POST["ds_branch3"]));
	$nm_area  = trim(avoid_crack($_POST["nm_area"]));
//	$nm_area  = trim(avoid_crack(implode(",",$_POST["nm_area"])));
	$nm_title  = trim(avoid_crack($_POST["nm_title"]));
	$nm_file  = trim(avoid_crack($_POST["nm_file"]));
	$nm_etc  = trim(avoid_crack($_POST["nm_etc"]));
	$nm_deposit  = trim(avoid_crack($_POST["nm_deposit"]));
	$dt_insert  = trim(avoid_crack($_POST["dt_insert"]));
	$nm_insert  = trim(avoid_crack($_POST["nm_insert"]));
	$dt_update  = trim(avoid_crack($_POST["dt_update"]));
	$nm_update  = trim(avoid_crack($_POST["nm_update"]));
	$ds_delind  = trim(avoid_crack($_POST["ds_delind"]));

	$ds_info_contract  = trim(avoid_crack($_POST["ds_info_contract"]));
	$ds_info_privacy  = trim(avoid_crack($_POST["ds_info_privacy"]));
	$ds_info_service  = trim(avoid_crack($_POST["ds_info_service"]));

//	$cd_procid = $_SESSION[admin_cd_dealerid];


//	$PageNo = trim(avoid_crack($_POST["PageNo"]));

	$upload_path =  $_SERVER['DOCUMENT_ROOT'].UPLOAD_PATH."dealer/";

	switch($mode) {
	//저장하기
	case "Add" :

		$_fields = Array(
				"cd_dealerid" => $cd_dealerid
				, "cd_dealer_p" => $cd_dealer_p
				, "nm_pass" => $nm_pass
				, "ds_type" => $ds_type
				, "ds_level" => $ds_level
				, "nm_company" => $nm_company
				, "nm_name" => $nm_name
				, "nm_birth" => $nm_birth
				, "nm_tel_01" => $nm_tel_01
				, "nm_tel_02" => $nm_tel_02
				, "nm_tel_03" => $nm_tel_03
				, "nm_hp_01" => $nm_hp_01
				, "nm_hp_02" => $nm_hp_02
				, "nm_hp_03" => $nm_hp_03
				, "nm_fax_01" => $nm_fax_01
				, "nm_fax_02" => $nm_fax_02
				, "nm_fax_03" => $nm_fax_03
				, "nm_email" => $nm_email
				, "nm_zip" => $nm_zip
				, "nm_addr" => $nm_addr
				, "nm_addr_sub" => $nm_addr_sub
				, "nm_etc_01" => $nm_etc_01
				, "nm_etc_02" => $nm_etc_02
				, "nm_etc_03" => $nm_etc_03
				, "ds_status" => $ds_status
				, "nm_company_biz" => $nm_company_biz
				, "nm_name_biz" => $nm_name_biz
				, "nm_no_biz" => $nm_no_biz
				, "nm_date_biz" => $nm_date_biz
				, "nm_type_biz" => $nm_type_biz
				, "nm_condition_biz" => $nm_condition_biz
				, "nm_tel_biz_01" => $nm_tel_biz_01
				, "nm_tel_biz_02" => $nm_tel_biz_02
				, "nm_tel_biz_03" => $nm_tel_biz_03
				, "nm_hp_biz_01" => $nm_hp_biz_01
				, "nm_hp_biz_02" => $nm_hp_biz_02
				, "nm_hp_biz_03" => $nm_hp_biz_03
				, "nm_fax_biz_01" => $nm_fax_biz_01
				, "nm_fax_biz_02" => $nm_fax_biz_02
				, "nm_fax_biz_03" => $nm_fax_biz_03
				, "nm_email_biz" => $nm_email_biz
				, "nm_zip_biz" => $nm_zip_biz
				, "nm_addr_biz" => $nm_addr_biz
				, "nm_addr_sub_biz" => $nm_addr_sub_biz
				, "ds_company_bp1" => $ds_company_bp1
				, "ds_branch1" => $ds_branch1
				, "ds_company_bp2" => $ds_company_bp2
				, "ds_branch2" => $ds_branch2
				, "ds_company_bp3" => $ds_company_bp3
				, "ds_branch3" => $ds_branch3
//				, "nm_area" => $nm_area
				, "nm_title" => $nm_title
//				, "nm_file" => $nm_file
				, "nm_etc" => $nm_etc
				, "nm_deposit" => $nm_deposit
				, "dt_insert" => now()
				, "nm_insert" => $nm_insert
				, "dt_update" => now()
				, "nm_update" => $nm_update
				, "ds_delind" =>  "N"
			);

		$result  = $dbCon->insertDAO($_fields,$table_name);
//echo $result;
//echo "<BR>";
		$cd_dealer  = mysql_insert_id();

		$sqlPwd="UPDATE dealer_master set nm_pass = password('".$nm_pass."'), cd_dealer_p = '".$cd_dealer."' where cd_dealer = '".$cd_dealer."'";
		$result  = $dbCon->query($sqlPwd);
//echo $result;
//echo "<BR>";
//exit;
		if ($result) {
			AlertRedirect("등록에 성공 하였습니다.","dealer.php");
		}else{
			AlertBack("등록 실패 하였습니다.");
		}

	break;

	//수정하기
	case "Update":

		if(empty($ds_info_contract)) {
			$ds_info_contract = 'N';
		}
		if(empty($ds_info_privacy)) {
			$ds_info_privacy = 'N';
		}
		if(empty($ds_info_service)) {
			$ds_info_service = 'N';
		}

		$_fields = Array(
				 "nm_company" => $nm_company
				, "nm_name" => $nm_name
				, "nm_birth" => $nm_birth
				, "nm_tel_01" => $nm_tel_01
				, "nm_tel_02" => $nm_tel_02
				, "nm_tel_03" => $nm_tel_03
				, "nm_hp_01" => $nm_hp_01
				, "nm_hp_02" => $nm_hp_02
				, "nm_hp_03" => $nm_hp_03
				, "nm_fax_01" => $nm_fax_01
				, "nm_fax_02" => $nm_fax_02
				, "nm_fax_03" => $nm_fax_03
				, "nm_email" => $nm_email
				, "nm_zip" => $nm_zip
				, "nm_addr" => $nm_addr
				, "nm_addr_sub" => $nm_addr_sub
				, "nm_etc_01" => $nm_etc_01
				, "nm_etc_02" => $nm_etc_02
				, "nm_etc_03" => $nm_etc_03
				, "nm_company_biz" => $nm_company_biz
				, "nm_name_biz" => $nm_name_biz
				, "nm_no_biz" => $nm_no_biz
				, "nm_date_biz" => $nm_date_biz
				, "nm_type_biz" => $nm_type_biz
				, "nm_condition_biz" => $nm_condition_biz
				, "nm_tel_biz_01" => $nm_tel_biz_01
				, "nm_tel_biz_02" => $nm_tel_biz_02
				, "nm_tel_biz_03" => $nm_tel_biz_03
				, "nm_hp_biz_01" => $nm_hp_biz_01
				, "nm_hp_biz_02" => $nm_hp_biz_02
				, "nm_hp_biz_03" => $nm_hp_biz_03
				, "nm_fax_biz_01" => $nm_fax_biz_01
				, "nm_fax_biz_02" => $nm_fax_biz_02
				, "nm_fax_biz_03" => $nm_fax_biz_03
				, "nm_email_biz" => $nm_email_biz
				, "nm_zip_biz" => $nm_zip_biz
				, "nm_addr_biz" => $nm_addr_biz
				, "nm_addr_sub_biz" => $nm_addr_sub_biz
//				, "ds_company_bp1" => $ds_company_bp1
//				, "ds_branch1" => $ds_branch1
//				, "ds_company_bp2" => $ds_company_bp2
//				, "ds_branch2" => $ds_branch2
//				, "ds_company_bp3" => $ds_company_bp3
//				, "ds_branch3" => $ds_branch3
//				, "nm_area" => $nm_area
				, "ds_info_contract" => $ds_info_contract
				, "ds_info_privacy" => $ds_info_privacy
				, "ds_info_service" => $ds_info_service

				, "nm_title" => $nm_title
				, "nm_etc" => $nm_etc
				, "nm_deposit" => $nm_deposit
				, "ds_status"=>$ds_status,
//				"dt_insert" => now(),
//				"nm_insert" => $cd_procid,
				"dt_update" => now(),
				"nm_update" => $cd_procid,
			);


		$result  = $dbCon->updateDAO($_fields,$table_name,"cd_dealer='".$cd_dealer."'");


		 if($_POST["nm_pass"]){

			$sqlPwd="UPDATE dealer_master set nm_pass = password('".$nm_pass."')  where cd_dealer = '".$cd_dealer."'";
			$result  = $dbCon->query($sqlPwd);
		 }

		if ($result) {
			AlertRedirect("수정 성공 하였습니다.","dealer.php");
		}else{
			AlertBack("수정 실패 하였습니다.");
		}
	break;

	//저장하기
	case "AddManager" :

		if (is_uploaded_file($_FILES['nm_file']['tmp_name'])) {
			if($_FILES['nm_file']['size'] > 0 ){
				$upload_file_name = upload($_FILES['nm_file'],$upload_path."nm_file/", 800, array('gif',  'jpeg', 'jpg','png','bmp' ,'ttif'));
				if($upload_file_name==false){
					AlertBack("첨부파일 업로드 실패 하였습니다.");
					die();
				}
			}
		}

		$_fields = Array(
				"cd_dealerid" => $cd_dealerid
				, "cd_dealer_p" => $cd_dealer_p
				, "nm_pass" => $nm_pass
				, "ds_type" => $ds_type
				, "ds_level" => $ds_level
				, "nm_company" => $nm_company
				, "nm_name" => $nm_name
				, "nm_birth" => $nm_birth
				, "nm_tel_01" => $nm_tel_01
				, "nm_tel_02" => $nm_tel_02
				, "nm_tel_03" => $nm_tel_03
				, "nm_hp_01" => $nm_hp_01
				, "nm_hp_02" => $nm_hp_02
				, "nm_hp_03" => $nm_hp_03
				, "nm_fax_01" => $nm_fax_01
				, "nm_fax_02" => $nm_fax_02
				, "nm_fax_03" => $nm_fax_03
				, "nm_email" => $nm_email
				, "nm_zip" => $nm_zip
				, "nm_addr" => $nm_addr
				, "nm_addr_sub" => $nm_addr_sub
				, "nm_etc_01" => $nm_etc_01
				, "nm_etc_02" => $nm_etc_02
				, "nm_etc_03" => $nm_etc_03
				, "ds_status" => $ds_status
				, "nm_company_biz" => $nm_company_biz
				, "nm_name_biz" => $nm_name_biz
				, "nm_no_biz" => $nm_no_biz
				, "nm_date_biz" => $nm_date_biz
				, "nm_type_biz" => $nm_type_biz
				, "nm_condition_biz" => $nm_condition_biz
				, "nm_tel_biz_01" => $nm_tel_biz_01
				, "nm_tel_biz_02" => $nm_tel_biz_02
				, "nm_tel_biz_03" => $nm_tel_biz_03
				, "nm_hp_biz_01" => $nm_hp_biz_01
				, "nm_hp_biz_02" => $nm_hp_biz_02
				, "nm_hp_biz_03" => $nm_hp_biz_03
				, "nm_fax_biz_01" => $nm_fax_biz_01
				, "nm_fax_biz_02" => $nm_fax_biz_02
				, "nm_fax_biz_03" => $nm_fax_biz_03
				, "nm_email_biz" => $nm_email_biz
				, "nm_zip_biz" => $nm_zip_biz
				, "nm_addr_biz" => $nm_addr_biz
				, "nm_addr_sub_biz" => $nm_addr_sub_biz
				, "ds_company_bp1" => $ds_company_bp1
				, "ds_branch1" => $ds_branch1
				, "ds_company_bp2" => $ds_company_bp2
				, "ds_branch2" => $ds_branch2
				, "ds_company_bp3" => $ds_company_bp3
				, "ds_branch3" => $ds_branch3
				, "nm_area" => $nm_area
				, "nm_title" => $nm_title
				, "nm_file" => $upload_file_name
				, "nm_etc" => $nm_etc
				, "dt_insert" => now()
				, "nm_insert" => $nm_insert
				, "dt_update" => now()
				, "nm_update" => $nm_update
				, "ds_delind" =>  "N"
			);

		$result  = $dbCon->insertDAO($_fields,$table_name);
//echo $result;
//echo "<BR>";
		$cd_dealer  = mysql_insert_id();

		$s_cd_dealer = $_SESSION[s_cd_dealer];

		$sqlPwd="UPDATE dealer_master set nm_pass = password('".$nm_pass."'), cd_dealer_p = '".$s_cd_dealer."' where cd_dealer = '".$cd_dealer."'";
		$result  = $dbCon->query($sqlPwd);
//echo $result;
//echo "<BR>";
//exit;
		if ($result) {
			AlertRedirect("등록에 성공 하였습니다.","dealer_view3.php?cd_dealer=$cd_dealer_p");
		}else{
			AlertBack("등록 실패 하였습니다.");
		}

	break;

	//수정하기
	case "UpdateManager":

		if (is_uploaded_file($_FILES['nm_file']['tmp_name'])) {
			if($_FILES['nm_file']['size'] > 0 ){
				$upload_file_name = upload($_FILES['nm_file'],$upload_path."nm_file/", 800, array('gif',  'jpeg', 'jpg','png','bmp' ,'ttif'));
				if($upload_file_name==false){
					AlertBack("첨부파일 업로드 실패 하였습니다.");
					die();
				}
			}
		}

		if(empty($ds_info_contract)) {
			$ds_info_contract = 'N';
		}
		if(empty($ds_info_privacy)) {
			$ds_info_privacy = 'N';
		}
		if(empty($ds_info_service)) {
			$ds_info_service = 'N';
		}

		if ($upload_file_name == ""){
		$_fields = Array(
				 "nm_company" => $nm_company
				, "nm_name" => $nm_name
				, "nm_birth" => $nm_birth
				, "nm_tel_01" => $nm_tel_01
				, "nm_tel_02" => $nm_tel_02
				, "nm_tel_03" => $nm_tel_03
				, "nm_hp_01" => $nm_hp_01
				, "nm_hp_02" => $nm_hp_02
				, "nm_hp_03" => $nm_hp_03
				, "nm_fax_01" => $nm_fax_01
				, "nm_fax_02" => $nm_fax_02
				, "nm_fax_03" => $nm_fax_03
				, "nm_email" => $nm_email
				, "nm_zip" => $nm_zip
				, "nm_addr" => $nm_addr
				, "nm_addr_sub" => $nm_addr_sub
				, "nm_etc_01" => $nm_etc_01
				, "nm_etc_02" => $nm_etc_02
				, "nm_etc_03" => $nm_etc_03
				, "ds_status" => $ds_status
				, "nm_company_biz" => $nm_company_biz
				, "nm_name_biz" => $nm_name_biz
				, "nm_no_biz" => $nm_no_biz
				, "nm_date_biz" => $nm_date_biz
				, "nm_type_biz" => $nm_type_biz
				, "nm_condition_biz" => $nm_condition_biz
				, "nm_tel_biz_01" => $nm_tel_biz_01
				, "nm_tel_biz_02" => $nm_tel_biz_02
				, "nm_tel_biz_03" => $nm_tel_biz_03
				, "nm_hp_biz_01" => $nm_hp_biz_01
				, "nm_hp_biz_02" => $nm_hp_biz_02
				, "nm_hp_biz_03" => $nm_hp_biz_03
				, "nm_fax_biz_01" => $nm_fax_biz_01
				, "nm_fax_biz_02" => $nm_fax_biz_02
				, "nm_fax_biz_03" => $nm_fax_biz_03
				, "nm_email_biz" => $nm_email_biz
				, "nm_zip_biz" => $nm_zip_biz
				, "nm_addr_biz" => $nm_addr_biz
				, "nm_addr_sub_biz" => $nm_addr_sub_biz
				, "ds_company_bp1" => $ds_company_bp1
				, "ds_branch1" => $ds_branch1
				, "ds_company_bp2" => $ds_company_bp2
				, "ds_branch2" => $ds_branch2
				, "ds_company_bp3" => $ds_company_bp3
				, "ds_branch3" => $ds_branch3
				, "nm_area" => $nm_area
				, "nm_title" => $nm_title
				, "ds_info_contract" => $ds_info_contract
				, "ds_info_privacy" => $ds_info_privacy
				, "ds_info_service" => $ds_info_service
				, "ds_status"=>$ds_status,

//				"dt_insert" => now(),
//				"nm_insert" => $cd_procid,
				"dt_update" => now(),
				"nm_update" => $cd_procid,
			);
		}else{
		$_fields = Array(
				 "nm_company" => $nm_company
				, "nm_name" => $nm_name
				, "nm_birth" => $nm_birth
				, "nm_tel_01" => $nm_tel_01
				, "nm_tel_02" => $nm_tel_02
				, "nm_tel_03" => $nm_tel_03
				, "nm_hp_01" => $nm_hp_01
				, "nm_hp_02" => $nm_hp_02
				, "nm_hp_03" => $nm_hp_03
				, "nm_fax_01" => $nm_fax_01
				, "nm_fax_02" => $nm_fax_02
				, "nm_fax_03" => $nm_fax_03
				, "nm_email" => $nm_email
				, "nm_zip" => $nm_zip
				, "nm_addr" => $nm_addr
				, "nm_addr_sub" => $nm_addr_sub
				, "nm_etc_01" => $nm_etc_01
				, "nm_etc_02" => $nm_etc_02
				, "nm_etc_03" => $nm_etc_03
				, "ds_status" => $ds_status
				, "nm_company_biz" => $nm_company_biz
				, "nm_name_biz" => $nm_name_biz
				, "nm_no_biz" => $nm_no_biz
				, "nm_date_biz" => $nm_date_biz
				, "nm_type_biz" => $nm_type_biz
				, "nm_condition_biz" => $nm_condition_biz
				, "nm_tel_biz_01" => $nm_tel_biz_01
				, "nm_tel_biz_02" => $nm_tel_biz_02
				, "nm_tel_biz_03" => $nm_tel_biz_03
				, "nm_hp_biz_01" => $nm_hp_biz_01
				, "nm_hp_biz_02" => $nm_hp_biz_02
				, "nm_hp_biz_03" => $nm_hp_biz_03
				, "nm_fax_biz_01" => $nm_fax_biz_01
				, "nm_fax_biz_02" => $nm_fax_biz_02
				, "nm_fax_biz_03" => $nm_fax_biz_03
				, "nm_email_biz" => $nm_email_biz
				, "nm_zip_biz" => $nm_zip_biz
				, "nm_addr_biz" => $nm_addr_biz
				, "nm_addr_sub_biz" => $nm_addr_sub_biz
				, "ds_company_bp1" => $ds_company_bp1
				, "ds_branch1" => $ds_branch1
				, "ds_company_bp2" => $ds_company_bp2
				, "ds_branch2" => $ds_branch2
				, "ds_company_bp3" => $ds_company_bp3
				, "ds_branch3" => $ds_branch3
				, "nm_area" => $nm_area
				, "nm_title" => $nm_title
				, "nm_file" => $upload_file_name
				, "ds_info_contract" => $ds_info_contract
				, "ds_info_privacy" => $ds_info_privacy
				, "ds_info_service" => $ds_info_service
				, "ds_status"=>$ds_status,

//				"dt_insert" => now(),
//				"nm_insert" => $cd_procid,
				"dt_update" => now(),
				"nm_update" => $cd_procid,
			);
		}

		$result  = $dbCon->updateDAO($_fields,$table_name,"cd_dealer='".$cd_dealer."'");


		 if($_POST["nm_pass"]){

			$sqlPwd="UPDATE dealer_master set nm_pass = password('".$nm_pass."')  where cd_dealer = '".$cd_dealer."'";
			$result  = $dbCon->query($sqlPwd);
		 }

		if ($result) {
			AlertRedirect("수정 성공 하였습니다.","dealer_view3.php?cd_dealer=$cd_dealer_p");
		}else{
			AlertBack("수정 실패 하였습니다.");
		}
	break;

	//삭제하기
	case "Delete" :

		$_fields = Array(
					"ds_delind"=>"Y",
					"dt_update" => now(),
					"nm_update" => $cd_procid
				);

		$result  = $dbCon->updateDAO($_fields,$table_name,"cd_dealer='".$cd_dealer."'");


		if ($result) {

			AlertRedirect("삭제 되었습니다.","list.php?PageNo=$PageNo");

		 }else{
			AlertRedirect("삭제 실패하였습니다.","list.php?PageNo=$PageNo");
		 }
	break;

	case "IdChk":

		$_whereis = "  cd_dealerid = '". $cd_dealerid . "'";

		$cnt = $dbCon->getOneDAO("count(*)",$table_name, $_whereis, 1);
		if($cnt==0) {
			echo("Y");
			exit;
		} else {
			echo("N");
			exit;
		}
	break;

	case "IdSearch":

		$_whereis = " ds_delind='N' And nm_name = '". $nm_name . "' AND nm_email = '". $nm_email . "'";

		$userid = $dbCon->getOneDAO("cd_dealerid",$table_name, $_whereis, 1);
		if($userid) {
			echo($userid);
			exit;
		} else {
			echo("");
			exit;
		}
	break;

	case "PwSearch":

		$_whereis = " ds_delind='N' And cd_dealerid = '".$cd_dealerid."' And nm_name = '". $nm_name . "' AND nm_email = '". $nm_email . "'";

		$userid = $dbCon->getOneDAO("cd_dealer",$table_name, $_whereis, 1);
		if($userid) {
			$new_passwd = generatePassword(8);

			$sqlPwd="UPDATE dealer_master set nm_pass = password('".$new_passwd."')  where cd_dealer = '".$userid."'";
			$result  = $dbCon->query($sqlPwd);

			echo($new_passwd);
			exit;
		} else {
			echo("");
			exit;
		}
	break;

	default :
		AlertBack("지정되지않은 요청입니다");
	break;
}
mysql_close($connect);
?>
