<?
/** 
 * @Project GoldMU.Net
 * @copyright 03/03/2022
 * @Email: goldmu.net@gmail.com
 * @Zalo: 0923 117 898
 */
 if (!defined('GoldWebMU')) die("Ban khong co quyen truy cap he thong");
include("config/config_webshop.php");
include('config/config_webshop_promotions.php'); 
$action = $_GET['iaction'];
$act = $_GET['iact'];
$slg = $_GET['islg'];			$slg = abs(intval($slg));	if($slg < 1 || $slg > 10) $slg = 0;
$giagoc = $_GET['igiagoc'];		$giagoc = abs(intval($giagoc));
$lvl = $_GET['ilvl'];     		$lvl = abs(intval($lvl));	if($lvl < 0 || $lvl > 15) $lvl = 0;
$opt = $_GET['iopt'];     		$opt = abs(intval($opt));	if($opt < 0 || $opt > 7) $opt = 0;
$Opt1 = $_GET['iOpt1'];
$Opt2 = $_GET['iOpt2'];
$Opt3 = $_GET['iOpt3'];
$Opt4 = $_GET['iOpt4'];
$Opt5 = $_GET['iOpt5'];
$Opt6 = $_GET['iOpt6'];
$Opt7 = $_GET['iOpt7'];			$Opt7 = abs(intval($Opt7));

switch ($action){
	case 'webshop':
		switch ($act){
			case 'shop_kiem': 
				$CatTem = 0;
				break;
			case 'shop_gay': 
				$CatTem = 1;
				break;
			case 'shop_cung': 
				$CatTem = 2;
				break;
			case 'shop_vukhikhac': 
				$CatTem = 3;
				break;
			case 'shop_khien': 
				$CatTem = 4;
				break;
			case 'shop_mu': 
				$CatTem = 5;
				break;
			case 'shop_ao': 
				$CatTem = 6;
				break;
			case 'shop_quan': 
				$CatTem = 7;
				break;
			case 'shop_tay': 
				$CatTem = 8;
				break;
			case 'shop_chan': 
				$CatTem = 9;
				break;
			case 'shop_canh': 
				$CatTem = 10;
				break;
			case 'shop_ring': 
				$CatTem = 11;
				break;
			case 'shop_pendant': 
				$CatTem = 12;
				break;
			case 'shop_canh3': 
				$CatTem = 13;
				break;
			default: $CatTem = ''; break;
		}

		$MaxLine = $MaxLine_Type[$CatTem];
		$Optvalue = '';
		
		$Optvalue = $Opt1.$Opt2.$Opt3.$Opt4.$Opt5.$Opt6;
		$Optlen = strlen($Optvalue);
		if ($Optlen>$MaxLine){
			echo "<font size='3' color='red'>Bạn chỉ được chọn $MaxLine dòng.</font>"; exit();
		}
		
		$sexc = array(
			(int)$Price_Opt1_Type[$CatTem],
			(int)$Price_Opt2_Type[$CatTem],
			(int)$Price_Opt3_Type[$CatTem],
			(int)$Price_Opt4_Type[$CatTem],
			(int)$Price_Opt5_Type[$CatTem],
			(int)$Price_Opt6_Type[$CatTem]
		);
		$MaxLine = (int)$MaxLine_Type[$CatTem];

		//Cal Price Item
		$Money=$giagoc;
		for($i = 0; $i < $MaxLine; $i++){
			$Money += $sexc[$Optvalue[$i]];
		}
		
		$Money += $Optlen*(int)$price_exc_line[$CatTem];
		
		$Money=$Money*$slg;
		
		// Opt
		switch ($opt){
			case 1:
			$Money += (int)$price_option1[$CatTem];
			break;
			case 2:
			$Money += (int)$price_option2[$CatTem];
			break;
			case 3:
			$Money += (int)$price_option3[$CatTem];
			break;
			case 4:
			$Money += (int)$price_option4[$CatTem];
			break;
			case 5:
			$Money += (int)$price_option5[$CatTem];
			break;
			case 6:
			$Money += (int)$price_option6[$CatTem];
			break;
			case 7:
			$Money += (int)$price_option7[$CatTem];
			break;
			default: $Money += 0;
		}
		
		// Lvl
		switch ($lvl){
			case 1:
			$Money += (int)$price_plus_lv1[$CatTem];
			break;
			case 2:
			$Money += (int)$price_plus_lv2[$CatTem];
			break;
			case 3:
			$Money += (int)$price_plus_lv3[$CatTem];
			break;
			case 4:
			$Money += (int)$price_plus_lv4[$CatTem];
			break;
			case 5:
			$Money += (int)$price_plus_lv5[$CatTem];
			break;
			case 6:
			$Money += (int)$price_plus_lv6[$CatTem];
			break;
			case 7:
			$Money += (int)$price_plus_lv7[$CatTem];
			break;
			case 8:
			$Money += (int)$price_plus_lv8[$CatTem];
			break;
			case 9:
			$Money += (int)$price_plus_lv9[$CatTem];
			break;
			case 10:
			$Money += (int)$price_plus_lv10[$CatTem];
			break;
			case 11:
			$Money += (int)$price_plus_lv11[$CatTem];
			break;
			case 12:
			$Money += (int)$price_plus_lv12[$CatTem];
			break;
			case 13:
			$Money += (int)$price_plus_lv13[$CatTem];
			break;
			case 14:
			$Money += (int)$price_plus_lv14[$CatTem];
			break;
			case 15:
			$Money += (int)$price_plus_lv15[$CatTem];
			break;
			default: $Money += 0;
		}
		
		//luck
		if($Opt7 == 1) $Money +=(int)$Price_Opt7_Type[$CatTem];
		
		if($Use_Promotion_Webshop && $timestamp>=strtotime($Promotion_Webshop_Start.' 00:00:00') && $timestamp<=strtotime($Promotion_Webshop_End.' 23:59:00'))
		{
			$Money = $Money -($Money*($Promotion_Webshop/100));
		}
		
		echo "<font color=yellow>Tổng giá trị: <b>".number_format($Money)." Gcoin</b></font>";
	break;
	
	case 'webshopkc':
		include("config/config_webshop_kc.php");
		switch ($act){
			case 'shop_kiem_kc': 
				$CatTem = 0;
				break;
			case 'shop_gay_kc': 
				$CatTem = 1;
				break;
			case 'shop_cung_kc': 
				$CatTem = 2;
				break;
			case 'shop_vukhikhac_kc': 
				$CatTem = 3;
				break;
			case 'shop_khien_kc': 
				$CatTem = 4;
				break;
			case 'shop_mu_kc': 
				$CatTem = 5;
				break;
			case 'shop_ao_kc': 
				$CatTem = 6;
				break;
			case 'shop_quan_kc': 
				$CatTem = 7;
				break;
			case 'shop_tay_kc': 
				$CatTem = 8;
				break;
			case 'shop_chan_kc': 
				$CatTem = 9;
				break;
			case 'shop_canh_kc': 
				$CatTem = 10;
				break;
			case 'shop_ring_kc': 
				$CatTem = 11;
				break;
			case 'shop_pendant_kc': 
				$CatTem = 12;
				break;
			case 'shop_canh3_kc': 
				$CatTem = 13;
				break;
			default: $CatTem = ''; break;
		}

		$MaxLine = $MaxLine_Type[$CatTem];
		$Optvalue = '';
		
		$Optvalue = $Opt1.$Opt2.$Opt3.$Opt4.$Opt5.$Opt6;
		$Optlen = strlen($Optvalue);
		if ($Optlen>$MaxLine){
			echo "<font size='3' color='red'>Bạn chỉ được chọn $MaxLine dòng.</font>"; exit();
		}
		
		$sexc = array(
			(int)$Price_Opt1_Type[$CatTem],
			(int)$Price_Opt2_Type[$CatTem],
			(int)$Price_Opt3_Type[$CatTem],
			(int)$Price_Opt4_Type[$CatTem],
			(int)$Price_Opt5_Type[$CatTem],
			(int)$Price_Opt6_Type[$CatTem]
		);
		$MaxLine = (int)$MaxLine_Type[$CatTem];

		//Cal Price Item
		$Money=$giagoc;
		for($i = 0; $i < $MaxLine; $i++){
			$Money += $sexc[$Optvalue[$i]];
		}
		
		$Money += $Optlen*(int)$price_exc_line[$CatTem];
		
		$Money=$Money*$slg;
		
		// Opt
		switch ($opt){
			case 1:
			$Money += (int)$price_option1[$CatTem];
			break;
			case 2:
			$Money += (int)$price_option2[$CatTem];
			break;
			case 3:
			$Money += (int)$price_option3[$CatTem];
			break;
			case 4:
			$Money += (int)$price_option4[$CatTem];
			break;
			case 5:
			$Money += (int)$price_option5[$CatTem];
			break;
			case 6:
			$Money += (int)$price_option6[$CatTem];
			break;
			case 7:
			$Money += (int)$price_option7[$CatTem];
			break;
			default: $Money += 0;
		}
		
		// Lvl
		switch ($lvl){
			case 1:
			$Money += (int)$price_plus_lv1[$CatTem];
			break;
			case 2:
			$Money += (int)$price_plus_lv2[$CatTem];
			break;
			case 3:
			$Money += (int)$price_plus_lv3[$CatTem];
			break;
			case 4:
			$Money += (int)$price_plus_lv4[$CatTem];
			break;
			case 5:
			$Money += (int)$price_plus_lv5[$CatTem];
			break;
			case 6:
			$Money += (int)$price_plus_lv6[$CatTem];
			break;
			case 7:
			$Money += (int)$price_plus_lv7[$CatTem];
			break;
			case 8:
			$Money += (int)$price_plus_lv8[$CatTem];
			break;
			case 9:
			$Money += (int)$price_plus_lv9[$CatTem];
			break;
			case 10:
			$Money += (int)$price_plus_lv10[$CatTem];
			break;
			case 11:
			$Money += (int)$price_plus_lv11[$CatTem];
			break;
			case 12:
			$Money += (int)$price_plus_lv12[$CatTem];
			break;
			case 13:
			$Money += (int)$price_plus_lv13[$CatTem];
			break;
			case 14:
			$Money += (int)$price_plus_lv14[$CatTem];
			break;
			case 15:
			$Money += (int)$price_plus_lv15[$CatTem];
			break;
			default: $Money += 0;
		}
		
		//luck
		if($Opt7 == 1) $Money +=(int)$Price_Opt7_Type[$CatTem];
		
		echo "<font color=yellow>Tổng giá trị: <b>".number_format($Money)." KC</b></font>";
	break;
}
?>