<?php

/*
 * Output.class.php    (安装视图文件)
 * @projectname  UBOA
 * @package      
 * @author       UBOA
 * @copyright    UBOA
 * @license     
 * @version      2013-08-14
 */

class Output {

	public function outputHead($step = 0) {
        $qq = '官方QQ群：190953983 <a target="_blank" href="http://shang.qq.com/wpa/qunwpa?idkey=2250489cd78d63b4e55dc90f419bb99ae71dc95cfbade725e6cac4ad315cef6d"><img border="0" src="http://pub.idqqimg.com/wpa/images/group.png" alt="友博开源CRM事业交流群" title="友博开源CRM事业交流群"></a>';
        $vesionInfo = 'UBOA-CRM V1.0.2015.04.18';
		switch ($step) {
			case 1:
				$header = <<<HEADER1
				<div class="header">
					<h1>UBOA 安装向导</h1>
                    <span style="position:relative;top:-9px;">{$qq}</span><span>{$vesionInfo}</span>	<div class="setup step1">
						<h2>开始安装</h2>
						<p>环境以及文件目录权限检查</p>
					</div>
					<div class="stepstat">
						<ul>
							<li class="current">检查安装环境</li>
							<li class="unactivated">创建数据库</li>
							<li class="unactivated last">安装</li>
						</ul>
						<div class="stepstatbg stepstat1"></div>
					</div>
				</div>
HEADER1;
				break;
			case 2:
				$header = <<<HEADER1
				<div class="header">
					<h1>UBOA 安装向导</h1>
					<span style="position:relative;top:-9px;">{$qq}</span><span>{$vesionInfo}</span>	<div class="setup step2">
						<h2>安装数据库</h2>
						<p>正在执行数据库安装</p>
					</div>
					<div class="stepstat">
						<ul>
							<li class="">检查安装环境</li>
							<li class="current">创建数据库</li>
							<li class="unactivated last">安装</li>
						</ul>
						<div class="stepstatbg stepstat1"></div>
					</div>
				</div>
HEADER1;
				break;
				case 3:
					$header = <<<HEADER1
					<div class="header">
						<h1>UBOA 安装向导</h1>
						<span style="position:relative;top:-9px;">{$qq}</span><span>{$vesionInfo}</span>
						<div class="setup step3">
							<h2>安装数据库</h2>
							<p>正在执行数据库安装</p>
						</div>
						<div class="stepstat">
							<ul>
								<li class="">检查安装环境</li>
								<li class="">创建数据库</li>
								<li class="current last">安装</li>
							</ul>
							<div class="stepstatbg stepstat1"></div>
						</div>
					</div>
HEADER1;
				break;
			default:
				$header = <<<HEADER
				<div class="header">
					<h1>UBOA 安装向导</h1>
					<span style="position:relative;top:-9px;">{$qq}</span><span>{$vesionInfo}</span>
				</div>
HEADER;
		}
		$head = <<<HEAD
		<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
		<link rel="stylesheet" href="Images/style.css" type="text/css" media="all" />
		<title>UBOA安装向导</title>
	</head>
	<body>
		<div class="container">
		{$header}
HEAD;
		return $head;
	}

	public function outputFoot() {
		$foot = <<<FOOT
        <div style="display:none;"> <script language="javascript" type="text/javascript" src="http://js.users.51.la/17789863.js"></script> <noscript><a href="http://www.51.la/?17789863" target="_blank"><img alt="&#x6211;&#x8981;&#x5566;&#x514D;&#x8D39;&#x7EDF;&#x8BA1;" src="http://img.users.51.la/17789863.asp" style="border:none" /></a></noscript> </div>
		<div class="footer">友博CRM客户管理系统 版权所有©<a href="http://www.u-bo.com/" target="_blank" >友博网络</a> </div>
		</div>

	</body>
</html>
FOOT;
		return $foot;
	}

	public function outputLicense($license = '') {
		$license = <<<LICENSE
		<div class="main" style="margin-top:-123px;">
				<div class="licenseblock">
				{$license}
				</div>
				<div class="btnbox marginbot">
					<form method="get" autocomplete="off" action="index.php">
						<input type="hidden" name="step" value="1" />
						<input type="submit" name="submit" value="我同意" style="padding: 2px" />&nbsp;
						<input type="button" name="exit" value="我不同意" style="padding: 2px" onclick="javascript: window.close();
								return false;" />
					</form>
				</div>		
			</div>
LICENSE;
		$head = $this->outputHead();
		$foot = $this->outputFoot();
		return $head . $license . $foot;
	}

	//输出步骤1
	public function outputStep1($step, $env = array(), $dirFile, $funsResult) {
		$phpVerClass = ($env['phpVersion']['status']) ? 'class="w pdleft1"' : 'class="nw pdleft1"';
		$gdVerClass = ($env['gdVersion']['status']) ? 'class="w pdleft1"' : 'class="nw pdleft1"';
		$checkResult = ($GLOBALS['installSuccess']) ? '<input type="button" onclick="history.back();" value="上一步"><input type="submit" value="下一步">' : '<input type="button" disabled="disabled" value="请修正错误后再试" />';
		$step1 = <<<STEP1
		<div class="main">
			<h2 class="title">环境检查</h2>
			<table class="tb" style="margin:20px 0 20px 55px;">
				<tr>
					<th>项目</th>
					<th class="padleft">UBOA 所需配置</th>
					<th class="padleft">UBOA 最佳</th>
					<th class="padleft">当前服务器</th>
				</tr>
				<tr>
					<td>操作系统</td>
					<td class="padleft">不限制</td>
					<td class="padleft">不限制</td>
					<td class="w pdleft1">{$env['system']['value']}</td>
				</tr>
				<tr>
					<td>PHP 版本</td>
					<td class="padleft">5.4</td>
					<td class="padleft">5.4</td>
					<td {$phpVerClass} >{$env['phpVersion']['value']}</td>
				</tr>
				<tr>
					<td>附件上传</td>
					<td class="padleft">不限制</td>
					<td class="padleft">2M</td>
					<td class="w pdleft1">{$env['uploadMaxSize']}</td>
				</tr>
				<tr>
					<td>GD 库</td>
					<td class="padleft">1.0</td>
					<td class="padleft">2.0</td>
					<td {$gdVerClass} >{$env['gdVersion']['value']}</td>
				</tr>
				<tr>
					<td>磁盘空间</td>
					<td class="padleft">20M</td>
					<td class="padleft">不限制</td>
					<td class="w pdleft1">{$env['space']}</td>
				</tr>
			</table>
			<h2 class="title">目录、文件权限检查</h2>
			<table class="tb" style="margin:20px 0 20px 55px;width:90%;">
				<tr>
					<th>目录文件</th>
					<th class="padleft">所需状态</th>
					<th class="padleft">当前状态</th>
				</tr>
				{$dirFile}
			</table>
			<h2 class="title">函数依赖性检查</h2>
			<table class="tb" style="margin:20px 0 20px 55px;width:90%;">
				<tr>
					<th>函数名称</th>
					<th class="padleft">检查结果</th>
					<th class="padleft">建议</th>
				</tr>
				{$funsResult}
			</table>
			<form action="index.php" method="get">
				<input type="hidden" name="step" value="2" />
					<div class="btnbox marginbot">
						{$checkResult}
					</div>
			</form>
		</div>
STEP1;
		$head = $this->outputHead($step);
		$foot = $this->outputFoot();
		return $head . $step1 . $foot;
	}

	//输出步骤2
	public function outputStep2($step) {
		$step2 = <<<STEP2
		<div class="main">
			<form method="post" action="index.php">
				<input type="hidden" name="step" value="3">
				<div id="form_items_3"><br /><div class="desc"><b>填写数据库信息</b></div><table class="tb2">
						<tr><th class="tbopt" align="left">&nbsp;数据库服务器:</th>
							<td><input type="text" name="dbinfo[dbhost]" value="localhost" size="35" class="txt"></td>
						</tr>

						<tr><th class="tbopt" align="left">&nbsp;数据库名:</th>
							<td><input type="text" name="dbinfo[dbname]" value="uboa_crm" size="35" class="txt"></td>
						</tr>

						<tr><th class="tbopt" align="left">&nbsp;数据库用户名:</th>
							<td><input type="text" name="dbinfo[dbuser]" value="root" size="35" class="txt"></td>
						</tr>

						<tr><th class="tbopt" align="left">&nbsp;数据库密码:</th>
							<td><input type="password" name="dbinfo[dbpw]" value="" size="35" class="txt"></td>
						</tr>

						<tr><th class="tbopt" align="left">&nbsp;数据库端口:</th>
							<td><input type="text" name="dbinfo[dbport]" value="3306" size="35" class="txt"></td>
						</tr>

						<tr><th class="tbopt" align="left">&nbsp;数据表前缀:</th>
							<td><input type="text" name="dbinfo[tablepre]" value="qc_" size="35" class="txt"></td>
						</tr>
					</table><div class="desc"><b>填写管理员信息</b></div><table class="tb2">
						<tr><th class="tbopt" align="left">&nbsp;管理员账号:</th>
							<td><input type="text" name="admininfo[username]" value="admin" size="35" class="txt"></td>
						</tr>

						<tr><th class="tbopt" align="left">&nbsp;管理员密码:</th>
							<td><input type="password" name="admininfo[password]" value="" size="35" class="txt"></td>
						</tr>

						<tr><th class="tbopt " align="left">&nbsp;重复密码:</th>
							<td><input type="password" name="admininfo[password2]" value="" size="35" class="txt"></td>
						</tr>
					</table></div><table class="tb2">
					<tr><th class="tbopt" align="left">&nbsp;</th>
						<td><input type="submit" name="submitname" value="下一步" onclick="javascript:this.value='正在安装中,请稍等...'" class="btn">
						</td>
						<td></td>
					</tr>
				</table>
			</form>
		</div>
STEP2;
		$head = $this->outputHead($step);
		$foot = $this->outputFoot();
		return $head . $step2 . $foot;
	}

	public function outputStep3($step,$process) {
		$notice=($GLOBALS['installSuccess'])?$process:'<span style="color:red;">'.$GLOBALS['installMsg'].'</span>';
		$checkResult=($GLOBALS['installSuccess'])?'<input type="submit" name="submit" value="完成安装" id="laststep" >':'<input type="button" onclick="history.back();" value="上一步">';
		$step3 = <<<STEP3
		<div class="main">
			<div id="notice">
				{$notice}
			</div>
			<div class="btnbox margintop marginbot">
				<form action="index.php" method="GET">
				<input type="hidden" name="step" value="4" />
				{$checkResult}
				</form>
			</div>
		</div>
STEP3;
		$head = $this->outputHead($step);
		$foot = $this->outputFoot();
		return $head . $step3 . $foot;
	}
	public function outputStep4($step){
        $dir = dirname(dirname($_SERVER['PHP_SELF']));
        $dir = ($dir == '/') ? '' : $dir;
		$step4 = <<<STEP4
		<div class="main" style="margin-top: -123px;">
			<ul style="line-height: 200%; margin-left: 30px;">
				<div id="platformIntro"><strong style="font-size:14px;">恭喜！您已经成功安装友博CRM客户管理系统</strong><br/><br/><p style="color:red;">为了系统安全，请删除web根目录下install文件夹</p><br/><a href="{$dir}/">进入网站前台</a><br/><a href="{$dir}/admin.php">进入网站管理后台</a><br/><a href="http://www.uboa.com.cn/" target="_blank">进入友博OA官方网站</a><br/><br/>
				</div>
			</ul>
		</div>
STEP4;
		$head = $this->outputHead($step);
		$foot = $this->outputFoot();
		return $head . $step4 . $foot;
	}

}

?>
