<?php
include ('includes/db1config.php');
include ('../includes/mysql_connect.php');
	
	$ssl_domain              = ( isset($_POST['ssl_domain'])      ? $_POST['ssl_domain']         : '' );
	$parent_site_url         = ( isset($_POST['parent_site_url']) ? $_POST['parent_site_url']    : '' );
	$sms_plan                = ( isset($_POST['sms_plan'])        ? $_POST['sms_plan']           : '' );
	$email_plan              = ( isset($_POST['email_plan'])      ? $_POST['email_plan']         : '' );
	$rocketblaster_id        = ( isset($_POST['rocketblaster_id'])? $_POST['rocketblaster_id']   : '' );
	$chow_now_id             = ( isset($_POST['chow_now_id'])     ? $_POST['chow_now_id'] 		 : '' );
	$sms_enabled             = ( isset($_POST['sms_enabled'])     ? $_POST['sms_enabled'] 		 : 0  );
	$use_linkpos             = ( isset($_POST['use_linkpos'])     ? $_POST['use_linkpos'] 		 : 0  );
	$auto_pkg                = ( isset($_POST['auto_pkg'])        ? $_POST['auto_pkg'] 			 : 0  );
	$ecommerce_pkg           = ( isset($_POST['ecommerce_pkg'])   ? $_POST['ecommerce_pkg'] 	 : 0  );
	$real_estate_pkg         = ( isset($_POST['real_estate_pkg']) ? $_POST['real_estate_pkg'] 	 : 0  );
	$coupon_pkg              = ( isset($_POST['coupon_pkg'])      ? $_POST['coupon_pkg'] 		 : 0  );
	$deal_site_pkg           = ( isset($_POST['deal_site_pkg'])   ? $_POST['deal_site_pkg'] 	 : 0  );
	$restaurant_pkg          = ( isset($_POST['restaurant_pkg'])  ? $_POST['restaurant_pkg']     : 0  );
	$hvac_pkg                = ( isset($_POST['hvac_pkg'])        ? $_POST['hvac_pkg']           : 0  );
	$enable_mobile           = ( isset($_POST['enable_mobile'])   ? $_POST['enable_mobile']      : 0  );
	$parent_pages_clickable  = ( isset($_POST['parent_pages_clickable']) ? $_POST['parent_pages_clickable'] : 0  );
	$horizontal_nav_enabled  = ( isset($_POST['horizontal_nav_enabled']) ? $_POST['horizontal_nav_enabled'] : 0  );
	$vertical_nav_enabled    = ( isset($_POST['vertical_nav_enabled'])   ? $_POST['vertical_nav_enabled']   : 0  );
	$enable_product_reviews  = ( isset($_POST['enable_product_reviews']) ? $_POST['enable_product_reviews'] : 0  );
	$enable_menu_reviews     = ( isset($_POST['enable_menu_reviews'])    ? $_POST['enable_menu_reviews']    : 0  );
	$online_ordering         = ( isset($_POST['online_ordering'])        ? $_POST['online_ordering']        : 0  );
	$fax_service             = ( isset($_POST['fax_service'])            ? $_POST['fax_service']            : 0  );
	$top_widgets             = ( isset($_POST['top_widgets'])            ? $_POST['top_widgets']            : '' );
	$bottom_widgets          = ( isset($_POST['bottom_widgets'])         ? $_POST['bottom_widgets']         : '' );
	$menu_boards             = ( isset($_POST['menu_boards'])            ? $_POST['menu_boards']            : '' );
	$number_of_menus         = ( isset($_POST['number_of_menus'])      ? $_POST['number_of_menus']      : '' );
	$text_notice_phone       = ( isset($_POST['text_notice_phone'])    ? $_POST['text_notice_phone']    : '' );
	$text_notice_enabled     = ( isset($_POST['text_notice_enabled'])  ? $_POST['text_notice_enabled']  : 0  );
	$tastepos_subscribed     = ( isset($_POST['tastepos_subscribed'])  ? $_POST['tastepos_subscribed']  : 0  );
	$orderOnline             = ( isset($_POST['orderOnline'])          ? $_POST['orderOnline']          : 0  );
	$store_record_key        = ( isset($_POST['recordKey'])            ? $_POST['recordKey']            : '' );


	$query = "SELECT * from admin_options where recordkey = 1";
	$rt    = mysql_query($query); // query executed
	echo mysql_error(); // if any error is there that will be printed to the screen
	$row   = mysql_fetch_array($rt);
	if( isset($row) && !empty($row) ){
		$query = "UPDATE admin_options SET ssl_domain='".mysql_escape_string($ssl_domain)."',parent_site_url='".mysql_escape_string($parent_site_url)."',sms_plan='".mysql_escape_string($sms_plan)."',email_plan='".mysql_escape_string($email_plan)."',rocketblaster_id='".mysql_escape_string($rocketblaster_id)."',chow_now_id='".mysql_escape_string($chow_now_id)."',sms_enabled='".mysql_escape_string($sms_enabled)."',use_linkpos='".mysql_escape_string($use_linkpos)."',auto_pkg='".mysql_escape_string($auto_pkg)."',ecommerce_pkg='".mysql_escape_string($ecommerce_pkg)."',real_estate_pkg='".mysql_escape_string($real_estate_pkg)."',coupon_pkg='".mysql_escape_string($coupon_pkg)."',deal_site_pkg='".mysql_escape_string($deal_site_pkg)."',restaurant_pkg='".mysql_escape_string($restaurant_pkg)."',hvac_pkg='".mysql_escape_string($hvac_pkg)."',enable_mobile='".mysql_escape_string($enable_mobile)."',parent_pages_clickable='".mysql_escape_string($parent_pages_clickable)."',horizontal_nav_enabled='".mysql_escape_string($horizontal_nav_enabled)."',vertical_nav_enabled='".mysql_escape_string($vertical_nav_enabled)."',enable_product_reviews='".mysql_escape_string($enable_product_reviews)."',enable_menu_reviews='".mysql_escape_string($enable_menu_reviews)."',online_ordering='".mysql_escape_string($online_ordering)."',fax_service='".mysql_escape_string($fax_service)."',top_widgets='".mysql_escape_string($top_widgets)."',bottom_widgets='".mysql_escape_string($bottom_widgets)."',menu_boards='".mysql_escape_string($menu_boards)."' WHERE recordkey = 1";
		mysql_query($query);   // query executed
		echo mysql_error();
	} else {
		$storeNew = "INSERT INTO admin_options (ssl_domain,parent_site_url,sms_plan,email_plan,rocketblaster_id,chow_now_id,sms_enabled,use_linkpos,auto_pkg,ecommerce_pkg,real_estate_pkg,coupon_pkg,deal_site_pkg,restaurant_pkg,hvac_pkg,enable_mobile,parent_pages_clickable,horizontal_nav_enabled,vertical_nav_enabled,enable_product_reviews,enable_menu_reviews,online_ordering,fax_service,top_widgets,bottom_widgets,menu_boards) VALUES ('".mysql_escape_string($ssl_domain)."','".mysql_escape_string($parent_site_url)."','".mysql_escape_string($sms_plan)."','".mysql_escape_string($email_plan)."','".mysql_escape_string($rocketblaster_id)."','".mysql_escape_string($chow_now_id)."','".mysql_escape_string($sms_enabled)."','".mysql_escape_string($use_linkpos)."','".mysql_escape_string($auto_pkg)."','".mysql_escape_string($ecommerce_pkg)."','".mysql_escape_string($real_estate_pkg)."','".mysql_escape_string($coupon_pkg)."','".mysql_escape_string($deal_site_pkg)."','".mysql_escape_string($restaurant_pkg)."','".mysql_escape_string($hvac_pkg)."','".mysql_escape_string($enable_mobile)."','".mysql_escape_string($parent_pages_clickable)."','".mysql_escape_string($horizontal_nav_enabled)."','".mysql_escape_string($vertical_nav_enabled)."','".mysql_escape_string($enable_product_reviews)."','".mysql_escape_string($enable_menu_reviews)."','".mysql_escape_string($online_ordering)."','".mysql_escape_string($fax_service)."','".mysql_escape_string($top_widgets)."','".mysql_escape_string($bottom_widgets)."','".mysql_escape_string($menu_boards)."')";
	    	mysql_query($storeNew) or die(mysql_error());
	}


	$query1 = "SELECT * from storePrefs where recordkey = 2";
	$rt     = mysql_query($query1); // query executed
	echo mysql_error(); // if any error is there that will be printed to the screen
	$row1   = mysql_fetch_array($rt);

	if( isset( $row1 ) && !empty($row1)){
		$query = "UPDATE storePrefs SET number_of_menus ='".mysql_escape_string($number_of_menus)."',text_notice_phone ='".mysql_escape_string($text_notice_phone)."',text_notice_enabled ='".mysql_escape_string($text_notice_enabled)."',tastepos_subscribed ='".mysql_escape_string($tastepos_subscribed)."',orderOnline ='".mysql_escape_string($online_ordering)."' WHERE recordkey = 2";
		mysql_query($query);   // query executed
		echo mysql_error();
	} else {
		$storeNew = "INSERT INTO storePrefs (number_of_menus,text_notice_phone,text_notice_enabled,tastepos_subscribed,orderOnline) VALUES ( '".mysql_escape_string($number_of_menus)."','".mysql_escape_string($text_notice_phone)."','".mysql_escape_string($text_notice_enabled)."','".mysql_escape_string($tastepos_subscribed)."','".mysql_escape_string($orderOnline)."')";
	    	mysql_query($storeNew) or die(mysql_error());
	}

echo "<center><h2>Record Successfully Updated</h2></center>";
echo "<script> setTimeout(function(){ parent.location.reload(true); }, 1000);</script>";
?>
