
<?php

session_start();
@ob_start();
include "../../config/koneksi.php";

$module=$_GET[module];
$act=$_GET[act];
 
// Input YM
if ($module=='reg' AND $act=='input'){
	$cek = mysql_query("Select * from customer where email = '$_POST[email]'");
	$ketemu = mysql_num_rows($cek);
	

		  $passw = md5($_POST[passw]);
		  $acti = rand(1000,9999);
		  mysql_query("INSERT INTO customer(nama,passw,alamat,email,telp,memo,acti,tgllahir) VALUES('$_POST[nama]','$passw','$_POST[alamat]','$_POST[email]','$_POST[telp]','$_POST[passw]','$acti','$_POST[dob]')");
		  $to = $_POST[email];
		  $link = "http://milokaraoke.com/milo/activation.php?i=".$to."&a=".$acti;
		  $email_subject = 'Activation to Milo Family Karaoke Online Reservation';
		  $email_body = "Hi,\n\nYou have received a new message from Milo Family Karaole Online Reservation Registration form.\n\n"."Here are the details:\n\nName: $_POST[nama]\n\nActivation Code: $acti \n\nor click this link for activation $link";
		  $headerss = "From: noreply@milokaraoke.com\n"; 


		  
		  mail($to,$email_subject,$email_body,$headerss);
		  //echo "<script>alert('Anda telah berhasil registrasi'); window.location = 'index.php'</script>";
		  
		  header('location:activation.php?i='.$_POST[email].'&module=reg');

}

elseif ($module=='cust' AND $act=='add'){
	$sales = $_SESSION['idm'];
	$isi   = $_POST['isi'];
	
	mysql_query("INSERT INTO iklan(cs,nama,category,sales,isi,produk) VALUES('$_POST[cs]','$_POST[nomor]','$_POST[cat]','$sales','$isi','$_POST[produk]')");
	header('location:data.php');

}

elseif ($module=='cust' AND $act=='edit'){
	mysql_query("update iklan set cs = '$_POST[cs]', nama = '$_POST[nomor]', category ='$_POST[cat]', isi ='$_POST[isi]', produk ='$_POST[produk]' where id = $_GET[id]");
	header('location:data.php');

}
elseif ($module=='cust' AND $act=='delete'){
	mysql_query("update iklan set status = 'N' where id = $_GET[id]");
	header('location:data.php');

}elseif ($module=='cust' AND $act=='delhasil'){
	mysql_query("delete from iklanhasil where pk = $_GET[id]");
	header('location:evaluasi.php?id='.$_GET['iklan']);

}elseif ($module=='cust' AND $act=='addev'){
	$id=$_GET[id];
	$sales = $_SESSION['nama'];
	
	mysql_query("insert into iklanhasil(iklan,tanggal,cost,tanya,remarks,kasir) values('$id','$_POST[tgl]','$_POST[cost]','$_POST[tanya]','$_POST[remarks]','$sales')");
	header('location:evaluasi.php?id='.$id);

}elseif ($module=='cust' AND $act=='editev'){
	$id=$_GET[id];
	$iklan=$_GET[iklan];

	mysql_query("update iklanhasil set cost = '$_POST[cost]',remarks='$_POST[remarks]' where pk = $id");
	header('location:evaluasi.php?id='.$iklan);

}elseif ($module=='cust' AND $act=='addprospek'){
	$sales = $_SESSION['nama'];
	
	mysql_query("insert into tmpprospek(iklan,nama,status,keterangan,kasir) values('$_POST[iklan]','$_POST[nama]','$_POST[status]','$_POST[ket]','$sales')");
	header('location:addprospek2.php');

}elseif ($module=='cust' AND $act=='delitemprospek'){
	$sales = $_SESSION['nama'];
	
	mysql_query("delete from tmpprospek where id = $_GET[id]");
	header('location:addprospek2.php');

}elseif ($module=='cust' AND $act=='addallprospek'){
	$kasir2	= $_SESSION['nama'];
	$cek = mysql_query("Select * from tmpprospek where kasir = '$kasir2'");
	while ($r=mysql_fetch_array($cek)){	
		$iklan = $r['iklan'];
		$nama = $r['nama'];
		$status = $r['status'];
		$kasir = $r['kasir'];
		$ket = $r['keterangan'];
		$dt1 = date("Y-m-d");

		mysql_query("INSERT INTO iklanprospek(iklan,tanggal,nama,status,remarks,kasir) VALUES('$iklan','$dt1','$nama','$status','$ket','$kasir')");
	}
	mysql_query("delete from tmpprospek where kasir = '$kasir'");
	header('location:prospekdetails.php');
}elseif ($module=='cust' AND $act=='delprospek'){
	mysql_query("update iklanprospek set aktif ='N' where pk = $_GET[id]");
	header('location:prospekdetails.php');

}elseif ($module=='cust' AND $act=='prospekup'){
	$skrg = mysql_result(mysql_query("select status from iklanprospek where pk = $_GET[id]"),0);
	if($skrg == "Tanya Tanya"){
		$status = "Totalan";
	}elseif($skrg == "Totalan"){
		$status = "Belanja";
	}elseif($skrg == "Belanja"){
		$status = "Close";
	}else{
		$status = "Tanya Tanya";
	}
	mysql_query("update iklanprospek set status ='$status' where pk = $_GET[id]");
	header('location:prospekdetails.php');
}elseif ($module=='cust' AND $act=='filter'){
	$status=$_GET['status'];
	$awal = $_POST['awal'];
	$akhir = $_POST['akhir'];

	header('location:prospekdetails.php?status='.$status.'&tglawal='.$awal.'&tglakhir='.$akhir);
	
}elseif ($module=='cust' AND $act=='prospekdown'){
	$skrg = mysql_result(mysql_query("select status from iklanprospek where pk = $_GET[id]"),0);
	if($skrg == "Tanya Tanya"){
		$status = "Close";
	}elseif($skrg == "Totalan"){
		$status = "Tanya Tanya";
	}elseif($skrg == "Belanja"){
		$status = "Tanya Tanya";
	}else{
		$status = "Close";
	}
	mysql_query("update iklanprospek set status ='$status' where pk = $_GET[id]");
	header('location:prospekdetails.php');

}elseif ($module=='cust' AND $act=='editprospek'){
	mysql_query("update iklanprospek set nama = '$_POST[nama]', status = '$_POST[status]' , remarks = '$_POST[remarks]' where pk = $_GET[id]");
	header('location:prospekdetails.php?id='.$_GET['prospek']);

}elseif ($module=='lap' AND $act=='evaluasi'){
	$awal = $_POST['awal'];
	$akhir = $_POST['akhir'];
	$id = $_GET['id'];
	header('location:evaluasi.php?id='.$id.'&tglawal='.$awal.'&tglakhir='.$akhir);

}

?>
