<!DOCTYPE html>
<html lang="en">
	<head>
        <meta charset="utf-8" />
        <title>$sys_title</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta content="width=device-width, initial-scale=1" name="viewport" />
        <meta content="$sys_title" name="description" />
        <meta content="" name="author" />
        
        <link href="$_dstroot/css/installation.css" rel="stylesheet" type="text/css" />
        
        <link rel="shortcut icon" href="favicon.ico" /> 
        <style>


        </style>
	</head>
	
	<body class="page-sidebar-closed-hide-logo page-container-bg-solid page-boxed page-footer-fixed">  
		<div class="container">      
    		<div class="page-header navbar">
    			<div class="page-header-top">
    					<div><span class='title'>$sys_install_title </span> $sys_install_subtitle </div>
    			</div>				
    		</div>
		
		
			<div class="page-container">
				<div class="page-content-wrapper">
					<div class="page-content">
						<div class="row">
							<div class="col-md-12">
								<div class="portlet ">
									<div class="portlet-body">
										<div class="row">
										<div class="col-md-3">
											<div class="portlet light ">
													<div class="portlet-title">
														<div class="caption">
                                        <span class="caption-subject bold uppercase"> 安装步骤
                                        </span>
                                    </div>
														</div>
													<div class="portlet-body amenu">
														<ul>
															<li class='active'>第一步：安装说明</li>
															<li>第二步：安装协议</li>
															<li>第三步：安装检查</li>
															<li>第四步：必选配置</li>
															<li>第五步：可选配置</li>															
															<li>第六步：确认安装</li>															
														</ul>	
													</div>
												</div>
												
											</div>
											
											<div class="col-md-9">
												<div class="portlet light " id="form_wizard_1">
                                <div class="portlet-title">
                                    <div class="caption">
                                        <i class=" icon-layers font-red"></i>
                                        <span class="caption-subject font-blue bold uppercase"> 安装向导 -
                                            <span class="step-title"> 第 1 步 </span>
                                        </span>
                                    </div>
                                    <div class="actions">
                                        
                                    </div>
                                </div>
                                <div class="portlet-body form">
                                    <form class="form-horizontal" action="#" id="submit_form" method="POST">
                                        <div class="form-wizard">
                                            <div class="form-body">
                                                <ul class="nav nav-pills nav-justified steps">
                                                	 <li>
                                                        <a href="#tab1" data-toggle="tab" class="step">
                                                            <span class="number"> 1 </span>
                                                            <span class="desc">
                                                                <i class="fa fa-check"></i> 安装说明 </span>
                                                        </a>
                                                    </li>
                                                    
                                                    <li>
                                                        <a href="#tab2" data-toggle="tab" class="step">
                                                            <span class="number"> 2 </span>
                                                            <span class="desc">
                                                                <i class="fa fa-check"></i> 安装协议 </span>
                                                        </a>
                                                    </li>
                                                    
                                                    <li>
                                                        <a href="#tab3" data-toggle="tab" class="step">
                                                            <span class="number"> 3 </span>
                                                            <span class="desc">
                                                                <i class="fa fa-check"></i> 安装检查 </span>
                                                        </a>
                                                    </li>
                                                    <li>
                                                        <a href="#tab4" data-toggle="tab" class="step">
                                                            <span class="number"> 4 </span>
                                                            <span class="desc">
                                                                <i class="fa fa-check"></i> 必选配置 </span>
                                                        </a>
                                                    </li>
                                                    <li>
                                                        <a href="#tab5" data-toggle="tab" class="step active">
                                                            <span class="number"> 5 </span>
                                                            <span class="desc">
                                                                <i class="fa fa-check"></i> 可选配置 </span>
                                                        </a>
                                                    </li>
                                                    <li>
                                                        <a href="#tab6" data-toggle="tab" class="step">
                                                            <span class="number"> 6 </span>
                                                            <span class="desc">
                                                                <i class="fa fa-check"></i> 确认安装 </span>
                                                        </a>
                                                    </li>
                                                </ul>
                                                <div id="bar" class="progress progress-striped" role="progressbar">
                                                    <div class="progress-bar progress-bar-success"> </div>
                                                </div>
                                                <div class="tab-content">
                                                    <div class="alert alert-danger display-none">
                                                        <button class="close" data-dismiss="alert"></button> 输入参数为空或无效，请检查！</div>
                                                    <div class="alert alert-success display-none">
                                                        <button class="close" data-dismiss="alert"></button> Your form validation is successful! </div>
                                                    <div class="tab-pane active" id="tab1">    
                                                        $params[description]                                                    	
                                                    </div>
                                                    <div class="tab-pane" id="tab2">
                                                    		$params[license]
                                                    		<p>
                                                    		<label class="checkbox-inline">
                                                    		<input type="checkbox" value="1" name="params[acceptproto]" id="param_acceptproto"> 接授协议 
                                                    		</label>
                                                    		</p>
                                                    </div>
                                                    <div class="tab-pane" id="tab3">
                                                    	<table class="table">
							                                            <thead>
							                                                <tr>
							                                                    <th> ID </th>
							                                                    <th> 描述 </th>
							                                                    <th> 建议配置 </th>
							                                                    <th> 当前配置 </th>
							                                                    <th> 状态 </th>
							                                                </tr>
							                                            </thead>
							                                            <tbody>
							                                                <tr>
							                                                    <td> 1 </td>
							                                                    <td> cache </td>
							                                                    <td> 读写 </td>
							                                                    <td id="cstatus-1"> <span class="label label-sm label-danger"> 否 </span> </td>
							                                                    <td id="cpass-1">
							                                                        <span class="label label-sm label-danger"> 否 </span>
							                                                    </td>
							                                                </tr>
							                                                
							                                                <tr>
							                                                    <td> 2 </td>
							                                                    <td> data </td>
							                                                    <td> 读写 </td>
							                                                    <td id="cstatus-2"> <span class="label label-sm label-danger"> 否 </span>  </td>
							                                                    <td id="cpass-2">
							                                                        <span class="label label-sm label-danger"> 否 </span>
							                                                    </td>
							                                                </tr>

							                                                <tr>
							                                                    <td> 3 </td>
							                                                    <td> config </td>
							                                                    <td> 读写 </td>
							                                                    <td id="cstatus-3"> <span class="label label-sm label-danger"> 否 </span>  </td>
							                                                    <td id="cpass-3">
							                                                        <span class="label label-sm label-danger"> 否 </span>
							                                                    </td>
							                                                </tr>
							                                                
							                                                <tr>
							                                                    <td> 4 </td>
							                                                    <td> SQL </td>
							                                                    <td> 支持 </td>
							                                                    <td id="cstatus-4"> <span class="label label-sm label-danger"> 否 </span>  </td>
							                                                    <td id="cpass-4">
							                                                        <span class="label label-sm label-danger"> 否 </span>
							                                                    </td>
							                                                </tr>
							                                                
							                                                
							                                                
							                                                <tr>
							                                                    <td> 5 </td>
							                                                    <td> CURL </td>
							                                                    <td> 支持 </td>
							                                                    <td id="cstatus-5"> <span class="label label-sm label-success"> 是 </span></td>
							                                                    <td id="cpass-5">
							                                                        <span class="label label-sm label-danger"> 否 </span>
							                                                    </td>
							                                                </tr>
							                                                
							                                                <tr>
							                                                    <td> 6 </td>
							                                                    <td> SSL </td>
							                                                    <td> 支持 </td>
							                                                    <td id="cstatus-6"> <span class="label label-sm label-danger"> 否 </span> </td>
							                                                    <td id="cpass-6">
							                                                        <span class="label label-sm label-danger"> 否 </span>
							                                                    </td>
							                                                </tr>
							                                            </tbody>
							                                        </table>
                                                    	
                                                    </div>
                                                    <div class="tab-pane" id="tab4">
                                                    	<h3 class="block">基本配置</h3>
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">系统名称
                                                                <span class="required"> * </span>
                                                            </label>
                                                            <div class="col-md-4">
                                                                <input type="text" class="form-control" name="params[product_name]" value="$params[product_name]" />
                                                                <span class="help-block"> 系统名称 </span>
                                                            </div>
                                                        </div>
                                                        
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">产品版本
                                                                <span class="required"> * </span>
                                                            </label>
                                                            <div class="col-md-4">
                                                                <input type="text" class="form-control" name="params[product_version]" value="$params[product_version]" disabled />
                                                            </div>
                                                        </div>
                                                        
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">产品ID
                                                                <span class="required"> * </span>
                                                            </label>
                                                            <div class="col-md-4">
                                                                <input type="text" class="form-control" name="params[product_id]" value="$params[product_id]" disabled />
                                                            </div>
                                                        </div>
                                                        
                                                        
                                                        <h3 class="block">数据库配置</h3>
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">数据库类型
                                                                <span class="required"> * </span>
                                                            </label>
                                                            <div class="col-md-4">
                                                                <select name="params[dbtype]" class="form-control">
                                                                	$dbtype_select
                                                                </select>
                                                            </div>
                                                            
                                                        </div>
                                                        
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">数据库服务器
                                                                <span class="required"> * </span>
                                                            </label>
                                                            <div class="col-md-4">
                                                                <input type="text" class="form-control" name="params[dbhost]" value="$params[dbhost]"/>
                                                                <span class="help-block"> 数据库服务IP或域名,如：127.0.0.1|127.0.0.1:3306 </span>
                                                            </div>
                                                        </div>
                                                       
                                                       <div class="form-group">
                                                            <label class="control-label col-md-3">数据库用户名
                                                                <span class="required"> * </span>
                                                            </label>
                                                            <div class="col-md-4">
                                                                <input type="text" class="form-control" name="params[dbuser]" value="$params[dbuser]" />
                                                                <span class="help-block"> 数据库用户名称，如果不存在，支持通过root新创建 </span>
                                                            </div>
                                                            <div class="col-md-3">
                                                            	<label class="checkbox-inline"><input type="checkbox" name="params[newdbuser]" value="1" /> 创建 </label>
                                                            </div>
                                                        </div>
                                                        
                                                        
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">数据库用户密码
                                                            </label>
                                                            <div class="col-md-4">
                                                                <input type="text" class="form-control" name="params[dbpassword]" value="$params[dbpassword]" />

                                                                <span class="help-block"> 数据库用户密码，如果新创建用户，会随数生成数据库用户密码 </span>

                                                            </div>
                                                        </div>
                                                        
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">数据库root密码
                                                            </label>
                                                            <div class="col-md-4">
                                                                <input type="text" class="form-control" name="params[dbroot_password]" />
                                                                <span class="help-block"> 当数据库用户名不存在，可以通过root自动创建，此时root密码必填 </span>
                                                            </div>
                                                        </div>
                                                        
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">数据库root新密码
                                                            </label>
                                                            <div class="col-md-4">
                                                                <input type="text" class="form-control" name="params[dbroot_password_reset]" />
                                                                <span class="help-block"> 支持安装重置数据库root密码，此处填写数据库root新密码 </span>
                                                            </div>
                                                        </div>
                                                        
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">数据库root新密码确认
                                                            </label>
                                                            <div class="col-md-4">
                                                                <input type="text" class="form-control" name="params[dbroot_password_reset2]" />
                                                            </div>
                                                        </div>
                                                        
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">数据库字符集
                                                            </label>
                                                            <div class="col-md-4">
                                                                <select name="params[dbcharset]" class="form-control">
                                                                	$dbcharset_select
                                                                </select>
                                                            </div>
                                                        </div>
                                                        
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">数据库名
                                                            </label>
                                                            <div class="col-md-4">
                                                                <input type="text" class="form-control" name="params[dbname]" value="$params[dbname]" />
                                                            </div>
                                                            <div class="col-md-3">
                                                            			<label class="checkbox-inline" > 
                                                            				<input type="checkbox" class="icheck" name="params[exists_rewrite]" value="1" $exists_rewrite_Y />存在覆盖
                                                            			</label>

                                                            			</div>	
                                                        </div>
                                                        
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">数据库表前缀
                                                            </label>
                                                            <div class="col-md-4">
                                                                <input type="text" class="form-control" name="params[prefix]" value="cms_" />
                                                            </div>
                                                        </div>
                                                        
                                                        <h3 class="block">管理员配置</h3>
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">管理员
                                                                <span class="required"> * </span>
                                                            </label>
                                                            <div class="col-md-4">
                                                                <input type="text" class="form-control" name="params[manager]" value="admin" />
                                                                <span class="help-block"> 初始系统管理员 </span>
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">初始管理员密码
                                                                <span class="required"> * </span>
                                                            </label>
                                                            <div class="col-md-4">
                                                                <input type="password" class="form-control" name="params[manager_pwd]" id="submit_form_password" />
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3"> 初始管理员密码确认
                                                                <span class="required"> * </span>
                                                            </label>
                                                            <div class="col-md-4">
                                                                <input type="password" class="form-control" name="params[manager_pwd2]"  />
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">初始管理员邮箱
                                                            </label>
                                                            <div class="col-md-4">
                                                                <input type="text" class="form-control" name="params[manager_email]" value="$params[manager_email]" />                                                                
                                                            </div>
                                                        </div>
                                                        
                                                        <h3 class="block">更新服务</h3>
                                                        
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">更新服务
                                                                <span class="required"> * </span>
                                                            </label>
                                                            <div class="col-md-4">
                                                                <select name="params[updatetype]" class="form-control">
                                                                	$updatetype_select
                                                                </select>
                                                            </div>
                                                            
                                                        </div>
                                                        
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">更新API
                                                                <span class="required"> * </span>
                                                            </label>
                                                            <div class="col-md-4">
                                                                 <input type="text" class="form-control" name="params[updateapi]" value="$params[updateapi]" />	
                                                                <span class="help-block"> eg: https://update.relaxcms.com/api </span>
                                                            </div>
                                                        </div>
                                                        
                                                        
                                                    </div>
                                                    <div class="tab-pane" id="tab5">
                                                    	<h3 class="block">选择应用</h3>
                                                        <table class="table ">
				                                            <thead>
				                                                <tr>
				                                                    <th> 
				                                                    	<label class="checkbox-inline"><input type="checkbox" name="checkall" class="checkall icheck"> ID 
				                                                    	</label>
				                                                    </th>
				                                                    <th> 名称 </th>
				                                                    <th> 描述 </th>
				                                                </tr>
				                                            </thead>
				                                            <tbody>
				                                            <!--# foreach($apps as $key=>$v) { #-->
				                                                <tr>
				                                                    <td> <label class="checkbox-inline"> 
				                                                    	<input type="checkbox" class="icheck"  name="params[app][]" value="$v[appname]" > $v[id] </label>
				                                                    </td>
				                                                    <td> $v[name] </td>
				                                                    <td> $v[description] </td>							                                                    
				                                                </tr>	
                                                            <!--# } #-->				                                                
				                                            </tbody>
				                                        </table>							                                        
                                                    </div>
                                                    
                                                    <div class="tab-pane" id="tab6">
                                                        <h3 class="block">确认配置</h3>
                                                        <h4 class="form-section">基本配置</h4>
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">系统名称:</label>
                                                            <div class="col-md-4">
                                                                <p class="form-control-static" data-display="params[product_name]"> </p>
                                                            </div>
                                                        </div>
                                                        
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">产品版本:</label>
                                                            <div class="col-md-4">
                                                                <p class="form-control-static" data-display="params[product_version]"> $params[product_version] </p>
                                                            </div>
                                                        </div>
                                                        
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">产品ID:</label>
                                                            <div class="col-md-4">
                                                                <p class="form-control-static" data-display="params[product_id]"> $params[product_id] </p>
                                                            </div>
                                                        </div>
                                                        <h4 class="form-section">数据库配置</h4>
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">数据库类型:</label>
                                                            <div class="col-md-4">
                                                                <p class="form-control-static" data-display="params[dbtype]"> </p>
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">数据库服务器 :</label>
                                                            <div class="col-md-4">
                                                                <p class="form-control-static" data-display="params[dbhost]"> </p>
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">数据库用户名:</label>
                                                            <div class="col-md-4">
                                                                <p class="form-control-static" data-display="params[dbuser]"> </p>
                                                            </div>
                                                        </div>
                                                        
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">数据库用户密码:</label>
                                                            <div class="col-md-4">
                                                                <p class="form-control-static" data-display="params[dbpassword]"> </p>
                                                            </div>
                                                        </div>

                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">数据库root密码:</label>
                                                            <div class="col-md-4">
                                                                <p class="form-control-static" data-display="params[dbroot_password]"> </p>
                                                            </div>
                                                        </div>

                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">重置数据库root密码:</label>
                                                            <div class="col-md-4">
                                                                <p class="form-control-static" data-display="params[dbroot_password_reset]"> </p>
                                                            </div>
                                                        </div>

                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">数据库字符集:</label>
                                                            <div class="col-md-4">
                                                                <p class="form-control-static" data-display="params[dbcharset]"> </p>
                                                            </div>
                                                        </div>

                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">数据库名:</label>
                                                            <div class="col-md-4">
                                                                <p class="form-control-static" data-display="params[dbname]"> </p>
                                                            </div>
                                                        </div>


                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">数据库表前缀:</label>
                                                            <div class="col-md-4">
                                                                <p class="form-control-static" data-display="params[prefix]"> </p>
                                                            </div>
                                                        </div>

                                                        
                                                        <h4>管理员配置</h4>
                                                        
                                                        
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">管理员 :</label>
                                                            <div class="col-md-4">
                                                                <p class="form-control-static" data-display="params[manager]"> </p>
                                                            </div>
                                                        </div>
                                                   
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">管理员邮箱 :</label>
                                                            <div class="col-md-4">
                                                                <p class="form-control-static" data-display="params[manager_email]"> </p>
                                                            </div>
                                                        </div>

                                                        <h4> 可选应用配置 </h4>
                                                        
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">可选应用:</label>
                                                            <div class="col-md-4">
                                                                <p class="form-control-static" data-display="params[app][]"> </p>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    
                                                    
                                                </div>
                                            </div>
                                            <div class="form-actions">
                                                <div class="row">
                                                    <div class="col-md-offset-3 col-md-9">
                                                        <a href="javascript:;" class="btn default button-previous">
                                                            <i class="fa fa-angle-left"></i> 上一步 </a>
                                                        <a href="javascript:;" class="btn btn-outline green button-next"> 下一步
                                                            <i class="fa fa-angle-right"></i>
                                                        </a>
                                                        <a href="javascript:;" class="btn green button-submit"> 安装
                                                            <i class="fa fa-check"></i>
                                                        </a>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                        	</div>
													<!-- END wizard -->
												
											</div>
											
										</div>
										
									</div>
								</div>
							</div>
							
							
							
							
						</div>
					</div>
				</div>
				<div class="page-quick-sidebar-wrapper" data-close-on-body-click="false">
				</div>
			</div>
			
    		<div class="page-footer ac ">
                <div class="page-footer-inner"><span class='powerby'>$sys_current_year &copy;<a href="https://www.relaxcms.com" target="_blank">RC</a> </span></div>
            </div>
        </div>
		
<script src="$_dstroot/js/installation.js" type="text/javascript"></script>
<!-- BEGIN GLOBAL VARIABLE G -->
$sys_JS_G
<!-- END GLOBAL VARIABLE G -->

<script type="text/javascript">
jQuery(document).ready(function() {
    if (!jQuery().bootstrapWizard) {
        return;
    }

    var form = $('#submit_form');
    var error = $('.alert-danger', form);
    var success = $('.alert-success', form);
    var G_checkenv_pass = false;

    form.validate({
        doNotHideMessage: true, //this option enables to show the error/success messages on tab switch.
        errorElement: 'span', //default input error message container
        errorClass: 'help-block help-block-error', // default input error message class
        focusInvalid: false, // do not focus the last invalid input
        rules: {
            'params[manager]': {
                minlength: 1,
                required: true
            },
            'params[manager_pwd]': {
                minlength: 5,
                required: true
            },
            'params[manager_pwd2]': {
                minlength: 5,
                required: true,
                equalTo: "#submit_form_password"
            },                    
        },

        messages: { // custom messages for radio buttons and checkboxes
             'params[manager]': {
                required: t("The field is required.")
            },
            'params[manager_pwd]': {
                required: t("The field is required.")
            },
            'params[manager_pwd2]': {
                required: t("The field is required.")
            }
                   
        },

        errorPlacement: function (error, element) { // render error placement for each input type
            if (element.attr("name") == "gender") { // for uniform radio buttons, insert the after the given container
                error.insertAfter("#form_gender_error");
            } else if (element.attr("name") == "payment[]") { // for uniform checkboxes, insert the after the given container
                error.insertAfter("#form_payment_error");
            } else {
                error.insertAfter(element); // for other inputs, just perform default behavior
            }
        },

        invalidHandler: function (event, validator) { //display error alert on form submit   
            success.hide();
            error.show();
            App.scrollTo(error, -200);
        },

        highlight: function (element) { // hightlight error inputs
            $(element)
                .closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group
        },

        unhighlight: function (element) { // revert the change done by hightlight
            $(element)
                .closest('.form-group').removeClass('has-error'); // set error class to the control group
        },

        success: function (label) {
            if (label.attr("for") == "gender" || label.attr("for") == "payment[]") { // for checkboxes and radio buttons, no need to show OK icon
                label
                    .closest('.form-group').removeClass('has-error').addClass('has-success');
                label.remove(); // remove error label here
            } else { // display success icon for other inputs
                label
                    .addClass('valid') // mark the current input as valid and display OK icon
                .closest('.form-group').removeClass('has-error').addClass('has-success'); // set success class to the control group
            }
        },

        submitHandler: function (form) {
            success.show();
            error.hide();
            form[0].submit();
            //add here some ajax code to submit your form or just call form.submit() if you want to submit the form without ajax
        }

    });

    var displayConfirm = function() {
        $('#tab6 .form-control-static', form).each(function(){
            var input = $('[name="'+$(this).attr("data-display")+'"]', form);
            if (input.is(":radio")) {
                input = $('[name="'+$(this).attr("data-display")+'"]:checked', form);
            }
            if (input.is(":text") || input.is("textarea")) {
                $(this).html(input.val());
            } else if (input.is("select")) {
                $(this).html(input.find('option:selected').text());
            } else if (input.is(":radio") && input.is(":checked")) {
                $(this).html(input.attr("data-title"));
            } else if ($(this).attr("data-display") == 'params[app][]') {
                var apps = [];
                $('[name="params[app][]"]:checked', form).each(function(){ 
                    apps.push($(this).val());
                });
                $(this).html(apps.join("<br>"));
            }
        });
    }

    var handleTitle = function(tab, navigation, index) {
        var total = navigation.find('li').length;
        var current = index + 1;
        // set wizard title
        $('.step-title', $('#form_wizard_1')).text('第 ' + (index + 1) + ' 步 ');
        // set done steps
        jQuery('li', $('#form_wizard_1')).removeClass("done");
        var li_list = navigation.find('li');
        for (var i = 0; i < index; i++) {
            jQuery(li_list[i]).addClass("done");
        }

        if (current == 1) {
            $('#form_wizard_1').find('.button-previous').hide();
        } else {
            $('#form_wizard_1').find('.button-previous').show();
        }

        if (current >= total) {
            $('#form_wizard_1').find('.button-next').hide();
            $('#form_wizard_1').find('.button-submit').show();
            displayConfirm();
        } else {
            $('#form_wizard_1').find('.button-next').show();
            $('#form_wizard_1').find('.button-submit').hide();
        }
        
       	$('.amenu > ul > li').each(function(i) {
       		if (i == index) {
       			$(this).addClass("active");
       		} else {
       			$(this).removeClass("active");
       		}
      	});
       
       
        
    }

    // default form wizard
    $('#form_wizard_1').bootstrapWizard({
        'nextSelector': '.button-next',
        'previousSelector': '.button-previous',
        onTabClick: function (tab, navigation, index, clickedIndex) {
            return false;
            /*success.hide();
            error.hide();
            if (form.valid() == false) {
                return false;
            }
            
            handleTitle(tab, navigation, clickedIndex);
            */
        },
        onNext: function (tab, navigation, index) {
            success.hide();
            error.hide();
            if (form.valid() == false) {                    		
                return false;
            }

            //检是否接授协议
            if (index == 2) {
            	var val = $('#param_acceptproto').prop("checked");
            	if (!val) {
            		return false;
            	}
            	
            	//获取运行环境状态
                var url = "$_base/checkenv?r="+Math.random();
                $.getJSON(url, function(res) {
                    if (res.status == 0) {
                        G_checkenv_pass = true;
                    } else {
                        G_checkenv_pass = false;
                    }
                    var cdb = res.data.cdb;
                    for(i=0; i<cdb.length; i++) {
                        if(cdb[i].pass) {
                            $("#cpass-"+cdb[i].id).html('<span class="label label-sm label-success"> 是 </span>');
                        } else {
                            $("#cpass-"+cdb[i].id).html('<span class="label label-sm label-danger"> 否 </span>');
                        }
                        $("#cstatus-"+cdb[i].id).html(cdb[i].status);
                    }

                    //更新其它配置
                    $('#param_product_version').val(res.data.product_version);
                    $('#param_product_id').val(res.data.product_id)
                });
            	
            	
            } else if (index == 3) {
            	//检查运行环境
                if (!G_checkenv_pass)                    	
                    return false;
            }
            
            handleTitle(tab, navigation, index);
        },
        onPrevious: function (tab, navigation, index) {
            success.hide();
            error.hide();

            handleTitle(tab, navigation, index);
        },
        onTabShow: function (tab, navigation, index) {
            var total = navigation.find('li').length;
            var current = index + 1;
            var percent = (current / total) * 100;
            $('#form_wizard_1').find('.progress-bar').css({
                width: percent + '%'
            });
        }
    });

    $('#form_wizard_1').find('.button-previous').hide();
    $('#form_wizard_1 .button-submit').click(function () {
       var  formData = $(form).serializeArray();
       //console.log(formData);  
       var url = G.basename+"/installation/setup?r="+Math.random();                            
       $.post(url, formData, function(res) {
            if (res.status == 0) {
                rui.showSuccess('安装成功.'); 
                rui.redirect(G._basename, 3);                                 
            } else {
               rui.showError('安装失败:'+res.status);
            }
        }).fail(function(){
             rui.showError('系统错误！');      
        });

    }).hide();

    //apply validation on select2 dropdown value change, this only needed for chosen dropdown integration.
    $('#param_acceptproto', form).change(function () {
        if (this.checked) {
        	$('#form_wizard_1 .button-next').attr("disabled",false);
        } else {
        	$('#form_wizard_1 .button-next').attr("disabled","disabled");
        }
    });
    
});
</script>

		</body>
</html>