<?
/** 
 * @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_webshopset.php");
include('config/config_webshop_promotions.php'); 
$action = $_GET['action'];
$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 'webshopset':
	$MaxLine = $MaxLine_Type;
	$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,
		(int)$Price_Opt2_Type,
		(int)$Price_Opt3_Type,
		(int)$Price_Opt4_Type,
		(int)$Price_Opt5_Type,
		(int)$Price_Opt6_Type
	);
	$MaxLine = (int)$MaxLine_Type;

	//Cal Price Item
	$Money=$giagoc;
	for($i = 0; $i < $MaxLine; $i++){
		$Money += $sexc[$Optvalue[$i]];
	}
	
	$Money += $Optlen*(int)$price_exc_line;
	
	// Opt
	switch ($opt){
		case 1:
		$Money += (int)$price_option1;
		break;
		case 2:
		$Money += (int)$price_option2;
		break;
		case 3:
		$Money += (int)$price_option3;
		break;
		case 4:
		$Money += (int)$price_option4;
		break;
		case 5:
		$Money += (int)$price_option5;
		break;
		case 6:
		$Money += (int)$price_option6;
		break;
		case 7:
		$Money += (int)$price_option7;
		break;
		default: $Money += 0;
	}
	
	// Lvl
	switch ($lvl){
		case 1:
		$Money += (int)$price_plus_lv1;
		break;
		case 2:
		$Money += (int)$price_plus_lv2;
		break;
		case 3:
		$Money += (int)$price_plus_lv3;
		break;
		case 4:
		$Money += (int)$price_plus_lv4;
		break;
		case 5:
		$Money += (int)$price_plus_lv5;
		break;
		case 6:
		$Money += (int)$price_plus_lv6;
		break;
		case 7:
		$Money += (int)$price_plus_lv7;
		break;
		case 8:
		$Money += (int)$price_plus_lv8;
		break;
		case 9:
		$Money += (int)$price_plus_lv9;
		break;
		case 10:
		$Money += (int)$price_plus_lv10;
		break;
		case 11:
		$Money += (int)$price_plus_lv11;
		break;
		case 12:
		$Money += (int)$price_plus_lv12;
		break;
		case 13:
		$Money += (int)$price_plus_lv13;
		break;
		case 14:
		$Money += (int)$price_plus_lv14;
		break;
		case 15:
		$Money += (int)$price_plus_lv15;
		break;
		default: $Money += 0;
	}
	
	//luck
	if($Opt7 == 1) $Money +=(int)$Price_Opt7_Type;
	
	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 'webshopsetkc':
	include("config/config_webshopset_kc.php");
	$MaxLine = $MaxLine_Type;
	$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,
		(int)$Price_Opt2_Type,
		(int)$Price_Opt3_Type,
		(int)$Price_Opt4_Type,
		(int)$Price_Opt5_Type,
		(int)$Price_Opt6_Type
	);
	$MaxLine = (int)$MaxLine_Type;

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