<?php
session_start();
if(!isset($_SESSION['user'])) {
	header("location: ../index.php");
	exit;
}

include '../dbconnect.php';

/******************************
	save filter data value
******************************/
if(isset($_POST['saveSetting'])){
	$filter_name = $_POST['filter_name'];

	$operator_outlet = $_POST['operator_outlet'];
	if($operator_outlet == '=') {
		$outlet_name = implode(',', $_POST['outlet_name']);
	}
	// $all_outlet = $_POST['all_outlet'];

	$last_visit = $_POST['operator_last_visit'];
	if ($last_visit == '=') {
		// $vdate = date('Y-m-d', strtotime($_POST['visit_date']));
		$vdate = $_POST['visit_date'];
		$exp = explode('/', $vdate);
		$visit_date = $exp[2].'-'.$exp[1].'-'.$exp[0];
	} else if($last_visit == 'between') {
		$visit_daterange = $_POST['visit_date'];
		$exp = explode(' - ', $visit_daterange);
		$fdt = explode('/', $exp[0]);
		$fdate = $fdt[2].'-'.$fdt[1].'-'.$fdt[0];
		$ldt = explode('/', $exp[1]);
		$ldate = $ldt[2].'-'.$ldt[1].'-'.$ldt[0];
                
       	/*$visit_daterange2 = $_POST['not_visit_date'];
		$exp2 = explode(' - ', $visit_daterange2);
		$fdt2 = explode('/', $exp2[0]);
		$fdate2 = $fdt2[2].'-'.$fdt2[1].'-'.$fdt2[0];
		$ldt2 = explode('/', $exp2[1]);
		$ldate2 = $ldt2[2].'-'.$ldt2[1].'-'.$ldt2[0];*/
	}
	
	$operator_spend = $_POST['operator_spend'];
	// $avg_spend_value = $_POST['avg_spend_value'];
	$avg_spend_value1 = $_POST['avg_spend_value1'];

	$operator_visits = $_POST['operator_visits'];
	$visits_value = $_POST['visits_value'];

	$operator_ordsrc = $_POST['operator_ordsrc'];
	if($operator_ordsrc == '=') {
		$order_source = implode(',', $_POST['order_source']);
		//$order_source_not = implode(',', $_POST['order_source_not']);
	}

	if ($_POST['item_group_name'] != '') {
		$itmgrpnm = $_POST['item_group_name'];
		if ($itmgrpnm == 'GroupName') {
			$grpname = implode(',', $_POST['groupname']);
		} else {
			$itmname = implode(',', $_POST['itemname']);
		}
	}
	
	$errormsg = array();
	if ($filter_name == '') {
		$errormsg['name_err'] = "Please enter filter name";
	}

	if (($operator_outlet == '0' && $operator_ordsrc == '0') && ($last_visit == '' && $operator_spend == '')) {
		$errormsg['opt_err'] = "please select operator";
	}

	if ($operator_outlet == '=' && $outlet_name == '') {
		$errormsg['outlet_err'] = "please select unitname";
	}

	if ($operator_ordsrc == '=' && $order_source == '') {
		$errormsg['source_err'] = "please select order source";
	}
	
	$_SESSION["error"] = $errormsg;

	if (!$_SESSION["error"]) {
		$qry = mysql_query("INSERT INTO `crm_my_filter`(`mf_name`, `mf_active`) VALUES ('$filter_name', 1)");
		$last_id = mysql_insert_id();

		if ($operator_outlet == '=') {
			$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Outlet', 'UnitId', '$operator_outlet', '$outlet_name', '1')");
		} else {
			$uid = array();
			$uqry = mysql_query("SELECT `UnitId` FROM `unit_master` WHERE `IsActive` = 1");
			while ($urow = mysql_fetch_assoc($uqry)) {
				$uid[] = $urow['UnitId'];			
			}
			$unitid = implode(',', $uid);
			$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Outlet', 'UnitId', '$operator_outlet', '$unitid', '1')");
		}
		
		if ($last_visit != '') {

			if ($last_visit == '=') {

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Sale Date Fixed', 'SaleDate', '$last_visit', '\'$visit_date\'', '2')");

			} elseif ($last_visit == 'between') {

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Sale Date Fixed', 'SaleDate', '>=', '\'$fdate\'', '2')");

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Sale Date Fixed', 'SaleDate', '<=', '\'$ldate\'', '2')");
                                
                /*$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Sale Date Fixed Not', 'SaleDate', '>=', '\'$fdate2\'', '2')");

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Sale Date Fixed Not', 'SaleDate', '<=', '\'$ldate2\'', '2')");*/

			} elseif ($last_visit == 'today') {

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Sale Date Dynamic', 'SaleDate', '=', 'CURDATE()', '2')");

			} elseif ($last_visit == 'yesterday') {

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Sale Date Dynamic', 'SaleDate', '=', 'SUBDATE(CURDATE(), INTERVAL 1 DAY)', '2')");

			} elseif ($last_visit == 'last7days') {

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Sale Date Dynamic', 'SaleDate', '>=', 'SUBDATE(CURDATE(), INTERVAL 6 DAY)', '2')");

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Sale Date Dynamic', 'SaleDate', '<=', 'CURDATE()', '2')");

			} elseif ($last_visit == 'last30days') {

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Sale Date Dynamic', 'SaleDate', '>=', 'SUBDATE(CURDATE(), INTERVAL 29 DAY)', '2')");

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Sale Date Dynamic', 'SaleDate', '<=', 'CURDATE()', '2')");

			} elseif ($last_visit == 'thismonth') {

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Sale Date Dynamic', 'SaleDate', '>=', 'LAST_DAY( CURDATE( ) - INTERVAL 1 MONTH ) + INTERVAL 1 DAY', '2')");

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Sale Date Dynamic', 'SaleDate', '<=', 'LAST_DAY( CURDATE( ) )', '2')");

			} elseif ($last_visit == 'lastmonth') {

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Sale Date Dynamic', 'SaleDate', '>=', 'LAST_DAY( CURDATE( ) - INTERVAL 2 MONTH ) + INTERVAL 1 DAY', '2')");

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Sale Date Dynamic', 'SaleDate', '<=', 'LAST_DAY( DATE_SUB( CURDATE( ) , INTERVAL 1 MONTH ) )', '2')");

			}

		}

		if ($operator_spend != '' || $avg_spend_value1 != '') {
			$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Bill Value', 'TotalAmt', '$operator_spend', '$avg_spend_value1', '3')");
		}

		if ($operator_visits != '' || $visits_value != '') {
			$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Visits', 'TotalOrder', '$operator_visits', '$visits_value', '4')");
		}
		
		if ($operator_ordsrc == '=') {
			$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Order Source', 'SourceId', '$operator_ordsrc', '$order_source', '5')");
			/*if(isset($order_source_not)){
				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Order Source Not', 'SourceId', '$operator_ordsrc', '$order_source_not', '5')");
			}*/
		} else {
			$sqry = mysql_query("SELECT `SourceId` FROM `ordersource` WHERE `Active` = 1");
			$os = array();
			while ($srow = mysql_fetch_array($sqry)) {
				$os[] = $srow['SourceId'];
			}
			$ord_src = implode(',', $os);
			$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Order Source', 'SourceId', '$operator_ordsrc', '$ord_src', '5')");
			
			
		}

		if ($_POST['item_group_name'] != '') {
			if ($_POST['item_group_name'] == 'GroupName') {
				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'Group Name', 'GroupName', '=', '$grpname', '6')");
			} else {
				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$last_id', 'item Name', 'ItemName', '=', '$itmname', '6')");
			}
		}
		
		
	}
	
	if ($qry) {
		$_SESSION['errTyp'] = "success";
		$_SESSION['msg'] = "New filter save successfully.";
	} else {
		$_SESSION['errTyp'] = "danger";
		$_SESSION['msg'] = "Filter not saved...please try again!";
	}

	header("location: manage_filter.php");
}

/**********************************
	update filter data value
**********************************/
if (isset($_POST['updateSetting'])) {
	 //echo "<pre>";
	 //print_r($_POST);
	 //exit();
	$mf_id = $_POST['mf_id'];
	$filter_name = $_POST['filter_name'];

	$operator_outlet = $_POST['operator_outlet'];
	$outlet_name = implode(',', $_POST['outlet_name']);
	// $all_outlet = $_POST['all_outlet'];

	$last_visit = $_POST['operator_last_visit'];
	if ($last_visit == '=') {
		$vdate = $_POST['visit_date'];
		$exp = explode('/', $vdate);
		$visit_date = $exp[2].'-'.$exp[1].'-'.$exp[0];
	} else {
		$visit_daterange = $_POST['visit_date'];
		$exp = explode(' - ', $visit_daterange);
		$fdt = explode('/', $exp[0]);
		$fdate = $fdt[2].'-'.$fdt[1].'-'.$fdt[0];
		$ldt = explode('/', $exp[1]);
		$ldate = $ldt[2].'-'.$ldt[1].'-'.$ldt[0];
	}
	
	$operator_spend = $_POST['operator_spend'];
	// $avg_spend_value = $_POST['avg_spend_value'];
	$avg_spend_value1 = $_POST['avg_spend_value1'];

	$operator_visits = $_POST['operator_visits'];
	$visits_value = $_POST['visits_value'];

	$operator_ordsrc = $_POST['operator_ordsrc'];
	$order_source = implode(',', $_POST['order_source']);

	if ($_POST['item_group_name'] != '') {
		$itmgrpnm = $_POST['item_group_name'];
		if ($itmgrpnm == 'GroupName') {
			$grpname = implode(',', $_POST['groupname']);
		} else {
			$itmname = implode(',', $_POST['itemname']);
		}
	}
	
	$up_qry = mysql_query("UPDATE `crm_my_filter` SET `mf_name` = '$filter_name' WHERE `mf_id` = '$mf_id'");

	$del_qry = mysql_query("DELETE FROM `crm_my_filter-values` WHERE `mf_id` = '$mf_id'");

	if ($operator_outlet == '=') {
		$up_qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$mf_id', 'Outlet', 'UnitId', '$operator_outlet', '$outlet_name', '1')");
	} else {
		$uid = array();
		$uqry = mysql_query("SELECT `UnitId` FROM `unit_master`");
		while ($urow = mysql_fetch_assoc($uqry)) {
			$uid[] = $urow['UnitId'];			
		}
		$unitid = implode(',', $uid);
		$up_qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$mf_id', 'Outlet', 'UnitId', '$operator_outlet', '$unitid', '1')");
	}
	
		if ($last_visit != '') {

			if ($last_visit == '=') {

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$mf_id', 'Sale Date Fixed', 'SaleDate', '$last_visit', '\'$visit_date\'', '2')");

			} elseif ($last_visit == 'between') {

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$mf_id', 'Sale Date Fixed', 'SaleDate', '>=', '\'$fdate\'', '2')");

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$mf_id', 'Sale Date Fixed', 'SaleDate', '<=', '\'$ldate\'', '2')");

			} elseif ($last_visit == 'today') {

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$mf_id', 'Sale Date Dynamic', 'SaleDate', '=', 'CURDATE()', '2')");

			} elseif ($last_visit == 'yesterday') {

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$mf_id', 'Sale Date Dynamic', 'SaleDate', '=', 'SUBDATE(CURDATE(), INTERVAL 1 DAY)', '2')");

			} elseif ($last_visit == 'last7days') {

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$mf_id', 'Sale Date Dynamic', 'SaleDate', '>=', 'SUBDATE(CURDATE(), INTERVAL 6 DAY)', '2')");

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$mf_id', 'Sale Date Dynamic', 'SaleDate', '<=', 'CURDATE()', '2')");

			} elseif ($last_visit == 'last30days') {

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$mf_id', 'Sale Date Dynamic', 'SaleDate', '>=', 'SUBDATE(CURDATE(), INTERVAL 29 DAY)', '2')");

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$mf_id', 'Sale Date Dynamic', 'SaleDate', '<=', 'CURDATE()', '2')");

			} elseif ($last_visit == 'thismonth') {

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$mf_id', 'Sale Date Dynamic', 'SaleDate', '>=', 'LAST_DAY( CURDATE( ) - INTERVAL 1 MONTH ) + INTERVAL 1 DAY', '2')");

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$mf_id', 'Sale Date Dynamic', 'SaleDate', '<=', 'LAST_DAY( CURDATE( ) )', '2')");

			} elseif ($last_visit == 'lastmonth') {

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$mf_id', 'Sale Date Dynamic', 'SaleDate', '>=', 'LAST_DAY( CURDATE( ) - INTERVAL 2 MONTH ) + INTERVAL 1 DAY', '2')");

				$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$mf_id', 'Sale Date Dynamic', 'SaleDate', '<=', 'LAST_DAY( DATE_SUB( CURDATE( ) , INTERVAL 1 MONTH ) )', '2')");

			}

		}

	if ($operator_spend != '') {
		$up_qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$mf_id', 'Bill Value', 'TotalAmt', '$operator_spend', '$avg_spend_value1', '3')");
	}

	if ($operator_visits != '' || $visits_value != '') {
			$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$mf_id', 'Visits', 'TotalOrder', '$operator_visits', '$visits_value', '4')");
		}
	
	if ($operator_ordsrc == '=') {
		$up_qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$mf_id', 'Order Source', 'SourceId', '$operator_ordsrc', '$order_source', '5')");
	} else {
		$sqry = mysql_query("SELECT `SourceId` FROM `ordersource` WHERE `Active` = 1");
		$os = array();
		while ($srow = mysql_fetch_array($sqry)) {
			$os[] = $srow['SourceId'];
		}
		$ord_src = implode(',', $os);
		$up_qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$mf_id', 'Order Source', 'SourceId', '$operator_ordsrc', '$ord_src', '5')");
	}

	if ($_POST['item_group_name'] != '') {
		if ($_POST['item_group_name'] == 'GroupName') {
			$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$mf_id', 'Group Name', 'GroupName', '=', '$grpname', '6')");
		} else {
			$qry .= mysql_query("INSERT INTO `crm_my_filter-values`(`mf_id`, `my_filter`, `my_filter_table_field`, `my_filter_operator`, `my_filter_options`, `my_filter_ord_seq`) VALUES('$mf_id', 'item Name', 'ItemName', '=', '$itmname', '6')");
		}
	}

	if ($up_qry) {
		$_SESSION['errTyp'] = "success";
		$_SESSION['update_msg'] = "Filter update successfully.";
	} else {
		$_SESSION['errTyp'] = "danger";
		$_SESSION['update_msg'] = "Filter not updated...please try again!";
	}

	header("location: manage_filter.php");
}


/* disable crm filter */
if ($_GET['act'] == 'crm_disable') {
	$mf_id = $_GET['mf_id'];
	$qry = mysql_query("update crm_my_filter set mf_active = 0 where mf_id= '$mf_id' ");
}
/* enable crm filter */
if ($_GET['act'] == 'crm_enable') {
	$mf_id = $_GET['mf_id'];
	$qry = mysql_query("update crm_my_filter set mf_active = 1 where mf_id= '$mf_id' ");
}
	
?>