<?php
$html = "";
$url = isset($_GET['url'])?$_GET['url']:"http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
$html .= "<form action='".$host."index.php?m=Order&a=aliziBooking' method='post' id='aliziForm'><input type='hidden' name='lang' value='".C('DEFAULT_LANG')."'><input type='hidden' name='user_id' value='{$_GET['uid']}'><input type='hidden' name='user_pid' value='{$_GET['pid']}'><input type='hidden' name='sn' value='{$info['sn']}'><input type='hidden' name='item_id' value='{$info['id']}'><input type='hidden' name='item_name' value='{$info['name']}'><input type='hidden' name='item_price' id='item_price' value='".($product?$product[0]['price']:$info['price'])."'><input type='hidden' name='url' value='{$url}'><input type='hidden' name='redirect' value='".($template['redirect_uri']?$template['redirect_uri']:$url)."'><input type='hidden' name='referer' value='{$referer}'><input type='hidden' name='order_page' value='{$request['page']}'><input type='hidden' name='channel_id' value='{$cookie['ac']}'><input type='hidden' name='qrcode_pay' value='{$info['qrcode_pay']}'><input type='hidden' name='math' value='{$paymentDefault['math']}'><input type='hidden' name='page' value='{$page}'><input type='hidden' name='alizi_token' value='{$token}'><input type='hidden' name='buy_num' value='{$info['buy_num']}'><input type='hidden' name='buy_num_decrease' value='{$info['buy_num_decrease']}'>";
	
if(!empty($template['info']) && $request['page'] == 'single'){
	$html .= "<div class='alizi-brief clearfix'>{$template['info']}</div>";
}

if(!empty($product)){
$html .= "<div class='alizi-rows clearfix rows-id-params rows-id-params-{$info['params_type']} alizi-{$info['params_type']}'><label class='rows-head'>".$package.lang('request')."</label><div class='rows-params'>";
		switch ($info['params_type']) {
			case 'select':
				$html .= "<select class='alizi-params-change' name='item_params[]' alizi-fx='alizi.quantity' alizi-fx-params='0'>";
					foreach($product as $vo){
						$html .= "<option value='{$vo['title']}' value-price='{$vo['price']}'>{$vo['title']}</option>";
					}
				$html .= "</select>";
			break;
			default:
				$i=0;
				foreach($product as $vo){
					$i++;
					$html .= "<label alizi-value='{$vo['price']}' alizi-target='#item_price' alizi-fx='alizi.quantity' alizi-fx-params='0' class='".($vo['image']?' alizi-params-image':' ellipsis')." alizi-params  alizi-{$info['params_type']}".($i==1?' active ':'')."' title='{$vo['title']}'>";
					if($vo['image']){
						$html .= "<p class='item-image'><img src='".imageUrl($vo['image'])."' /></p>";
					}
					$html .= "<p class='item-desc'><input type='{$info['params_type']}' name='item_params[]' value='{$vo['title']}' ".($i==1?'checked':'').">{$vo['title']}</p></label>";
				}
			break;
		}
	$html .= "</div></div>";
}

if(!empty($extends)){
	foreach($extends as $k=>$vo){
		//if($vo['type']=='text'){continue;}
		$disabled  = '';
		if(strstr($vo['title'],'#')){
			list($index,$vo['title'])= explode('#',$vo['title'],2);
			$item_index =1;
			$level = "1";
			if($index==1){
				$disabled = '';
				$class = "extends extends-{$index}";
			}else{
				$disabled = 'disabled';
				$class = "extends extends-hidden extends-{$index}";
			}
		}
		
		if(strstr($vo['title'],'#')){
			list($index2,$vo['title'])= explode('#',$vo['title'],2);
			
			if($index2==1){
				$disabled = '';
				$class2 = "subextends subextends-{$index2}";
			}else{
				$disabled = 'disabled';
				$class2 = "subextends subextends-hidden subextends-{$index2}";
			}
			$level = "2";
		}
		
		
		$html .= "<div data-level='{$level}' class='alizi-rows clearfix rows-id-extends {$class} {$class2} extends-level-{$level} alizi-{$vo['type']}'><label class='rows-head'>{$vo['title']}".lang('request')."</label><div class='rows-params'>";
		switch ($vo['type']) {
			case 'text':
				$html .= "<input type='text' name='extends[{$vo['title']}]' placeholder='{$vo['value']}' autocomplete='off' class='alizi-input-text' {$disabled} {$disabled2}>";
			break;
			case 'password':
				$html .= "<input type='password' name='extends[{$vo['title']}]' placeholder='{$vo['value']}' autocomplete='off' class='alizi-input-text' {$disabled} {$disabled2}>";
			break;
			case 'select':
				$html .= "<select name='extends[{$vo['title']}]' {$disabled} {$disabled2}>";
					foreach(explode('#',$vo['value']) as $li){
						if(empty($li)){
							$html .= "<option value=''>".lang('pleaseSelect')."</option>";
						}else{
							$html .= "<option value='{$li}'>{$li}</option>";
						}
					}
				$html .= "</select>";
			break;
			default:
				$i=0;
				foreach(explode('#',$vo['value']) as $li){
					$i++;
					$hidden = empty($li)?'style="display:none;"':'';
					$html .= "<label class='alizi-group alizi-params alizi-{$vo['type']} ".($i==1?'active':'')."' {$hidden}><span class='alizi-group-box'><input alizi-value='{$li}' class='{$vo['type']}-{$k}' id='{$vo['title']}{$key}' name='extends[{$vo['title']}]".($vo['type']=='checkbox'?'[]':'')."' type='{$vo['type']}' value='{$li}' ".($i==1?'checked':'')." {$disabled}><label class='selected-icon' for='{$vo['title']}{$key}'></label></span>{$li}</label>";
				}
			break;
		}
		$html .= "</div></div>";	
	}		
}

foreach($params as $key=>$vo){
	if(empty($vo['checked']) || in_array($key,array('product','extends'))){ continue;}
	$html .= "<div class='alizi-rows clearfix rows-id-{$key}'><label class='rows-head'>{$vo['name']}<span class='alizi-request ".($vo['request']?'':'alizi-request-none')."'>*</span></label><div class='rows-params'>";
	switch ($key) {
				
		case 'price':
			$html .= lang('symbol')."<strong class='alizi-total-price'>".$info['price']."</strong>";
	
		break;
		case 'payment':
			$html .= "<div class='alizi-payment clearfix'>";
			$i=0;
			$firstPayment =1;
			foreach($payment as $key=>$vo){
				if($key == 5 && empty($info['qrcode_pay'])){ continue;}
				$i++;
				if($i==1) $firstPayment=$key;
				$html .= "<label alizi-value='{$key}' alizi-target=':payment' alizi-fx='alizi.payment' alizi-fx-params='{$key}' class='ellipsis alizi-params alizi-payment-{$key} ".($i==1?'active':'')."'><input type='radio' name='payment' value='{$key}' ".($i==1?'checked':'').">{$vo['name']}</label>";
			}
			
			$html .= "</div>";	
		break;
		case 'mobile':
			$html .= "<input type='tel' name='{$key}' placeholder='{$vo['info']}' autocomplete='off' class='alizi-input-text' alizi-request='{$vo['request']}' value='{$cookie[$key]}'>";
		break;
		case 'salenum':
			$html .= "<span>{$info['salenum']}</span>";
		break;
		case 'quantity':
			$html .= "<input type='tel' class='alizi-quantity alizi-input-text' size='4' value='1' name='quantity'' style='width:50%;'>";
		break;
		case 'datetime':
			$date = date('Y-m-d',strtotime("+0 day"));
			$html .= "<input type='text' name='{$key}' placeholder='{$vo['info']}' autocomplete='off' class='alizi-input-text Wdate' alizi-request='{$vo['request']}' style='width:50%;' value='{$cookie[$key]}'>";
		break;
		case 'region':
			if(L('regions')=='' || L('regions')=='REGIONS'){
				$html .= "<select name='region[province]' id='province' class='alizi-region alizi-region-province' alizi-request='{$vo['request']}'></select>
					<select name='region[city]' id='city' class='alizi-region alizi-region-city' alizi-request='{$vo['request']}'></select>
					<select name='region[area]' id='area' class='alizi-region alizi-region-area' alizi-request='{$vo['request']}'></select>";
				
				$region = $host."/Public/Alizi/seajs/alizi/region-".C('DEFAULT_LANG').".js";
				$html .= "<script src='{$region}'></script><script>new PCAS('region[province]','region[city]','region[area]','{$cookie['region'][0]}','{$cookie['region'][1]}','{$cookie['region'][2]}');</script>";
					
			}else{
				$regions = explode(',',L('regions'));
				$region = '';
				foreach($regions as $reg){ $region .= "<option value='{$reg}'>{$reg}</option>";}
				$html .= "<select name='region[province]' id='province' class='alizi-region alizi-region-province' style='width:100% !important;'>{$region}</select>";
			}
		break;
		case 'remark':
			$html .= "<input type='text' name='{$key}' placeholder='{$vo['info']}' autocomplete='off' alizi-request='{$vo['request']}' class='alizi-input-text' value='{$cookie[$key]}'>";
		break;
		case 'verify':
			$verify= $host.'index.php?m=Alizi&a=verify';
			if(!empty($request['verify'])) $verify .= '&'.http_build_query($request['verify']);
			$html .= "<input type='tel' name='{$key}' placeholder='{$vo['info']}' class='alizi-input-text' autocomplete='off' alizi-request='{$vo['request']}' style='width:30%;'>
				<img class='verify' src='{$verify}' />";
		break;
		case 'code':
			$html .= "<input type='tel' name='{$key}' placeholder='{$vo['info']}' class='alizi-input-text' autocomplete='off' alizi-request='{$vo['request']}' style='width:50%;float:left;'>
				<a href='{$host}index.php?m=Order&a=getCode' target='_blank' class='alizi-btn-min alizi-btn alizi-btn-ok' style='width:48%;font-weight:normal;float:right;text-align:center;margin:0;padding:6px 0;font-size:14px;text-decoration:none;' />".lang('getMobileCode')."<i></i></a>";
		break;
		default:
			$html .= "<input type='text' name='{$key}' placeholder='{$vo['info']}' autocomplete='off' alizi-request='{$vo['request']}' class='alizi-input-text' value='{$cookie[$key]}'>";
		break;
	}
	$html .= "</div></div>";			
}

$html .=  "<input type='hidden' name='item_index' value='{$item_index}'>";
$html .= "<div class='alizi-rows alizi-id-btn clearfix'><input type='submit' id='alizi-submit' class='alizi-btn alizi-submit' value='".lang('orderSubmit')."' /></div></form>";
$html .= "<style>#aliziForm{color:#333;padding:5px;}#aliziForm *{margin:0;padding:0;font-size:14px;}#aliziForm .alizi-request{font-size:16px;font-weight:bold;color:#f60;float: left;display: inline-block;line-height:25px;margin-left: 3px;}#aliziForm .alizi-request-none{visibility: hidden;}#aliziForm .clearfix:before,#aliziForm .clearfix:after{content:'';display:table;}#aliziForm .clearfix:after{clear:both;}#aliziForm .clearfix{*zoom:1;}#aliziForm .alizi-rows{padding:3px 0;position: relative;text-align: center;}#aliziForm .rows-head{position:absolute;left:0;width:5rem;font-weight:normal;border-bottom:none;padding:2px 0;text-align:right;}#aliziForm .rows-params{margin-left: 5.5rem;text-align: left;}#aliziForm .alizi-params{display:block;color:#f00;padding:2px 0;}.alizi-params-image{margin-right:5px;float:left;max-width:30%;border:1px solid #ccc;}.alizi-params-image img{max-width:100%;}#aliziForm .alizi-payment .alizi-params{display:inline-block;margin-right:15px;font-weight:bold;}#aliziForm select,#aliziForm .alizi-input-text {float:left;text-indent:4px;width:100%;display: inline-block;padding:5px 0;margin-right:1px;color: #555555;border: 1px solid #cccccc;font-family:MicroSoft Yahei;outline:none;transition: all 0.2s linear 0s;box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);border-radius: 2px;font-size: 14px;}#aliziForm .alizi-total-price{color:#f00;font-size:18px;}#aliziForm .alizi-btn{margin:10px 0;width:98%;padding:10px;background: #EE3300;border: #EE3300;color:#fff;border-radius:5px;font-size:18px;cursor:pointer;}#aliziForm .alizi-btn:hover{opacity:0.9;}#aliziForm .alizi-region{width:33%;}#aliziForm .alizi-region-area{float:right;}";
if(!empty($template['color'])){
	$color = $template['color'];
    $html .= "#aliziForm{color:#{$color['font']};background-color:#{$color['form_bg']};}.alizi-title{background-color:#{$color['title_bg']};}#aliziForm .alizi-btn,#aliziForm .alizi-btn:hover, #aliziForm .alizi-btn:active,#aliziForm .alizi-group-box input:checked + label:after{background-color:#{$color['button_bg']};border-color:#{$color['button_bg']};}#aliziForm .alizi-params{color:#{$color['button_bg']};}";
}
$html .= "</style>";
return $html;
?>
