{template 'common/header'}
<ul class="we7-page-tab"></ul>
<div class="system-check" id="js-system-check" ng-controller="systemCheckCtrl" ng-cloak>
	<div class="system-check-header clearfix we7-margin-bottom">
		<a href="#" ng-click="checkAll()" class="btn btn-primary pull-right">检测</a>
	</div>
	<div>
		<table class="tbale we7-table">
			<tr>
				<th>全部检测{{ check_num }}项，错误检测项<span class="color-red">{{ check_wrong_num }}</span>项</th>
				<th>检测</th>
				<th>检测结果</th>
				<th>解决建议</th>
				<th>建议操作</th>
				<th>解决方案</th>
			</tr>

			<tr ng-repeat="(key, check_item) in system_check_items">
				<td>{{ check_item.description }}</td>
				<td>
					<a href="#" ng-click="checkSystem(key)" class="btn btn-primary">检测</a>
				</td>

				<td>
					<span class="color-red wi wi-info-sign" ng-show="check_item.check_result === false">{{check_item.error_message}}</span>
					<span class="color-green wi wi-right-sign" ng-show="check_item.check_result === true">正确</span>
					<span ng-show="check_item.check_result !== false && !check_item.check_result">--</span>
				</td>

				<td>
					<div>
						<a href="#" onclick="checkSystem(key)" ng-show="check_item.check_result === false">重新检测</a>
						<span ng-show="check_item.check_result === true">--</span>
						<span ng-show="check_item.check_result !== false && !check_item.check_result">--</span>
					</div>
				</td>

				<td>
					<span ng-show="check_item.check_result === false">{{check_item.solution}}</span>
					<span ng-show="check_item.check_result === true">--</span>
					<span ng-show="check_item.check_result !== false && !check_item.check_result">--</span>
				</td>

				<td>
					<a href="{{check_item.handle}}" target="_balnk"  ng-show="check_item.check_result === false">查看</a>
					<span ng-show="check_item.check_result === true">--</span>
					<span ng-show="check_item.check_result !== false && !check_item.check_result">--</span>
				</td>
			</tr>

			<!-- fpm 环境 start -->
			<tr>
				<td>php-fpm 运行环境</td>
				<td>
					<a href="#" ng-click="checkFpm(true)" class="btn btn-primary">检测</a>
				</td>
				<td ng-if="checkFpmStatus === 0"><span class="color-gray wi wi-info-sign">检测中...</span></td>
				<td ng-if="checkFpmStatus == 1"><span class="color-green wi wi-right-sign">正确</span></td>
				<td ng-if="checkFpmStatus == 2"><span class="color-red wi wi-info-sign">错误</span></td>
				<td ng-if="!checkFpmStatus && checkFpmStatus !== 0"><span>--</span></td>
				<td>
					<span ng-if="checkFpmStatus != 2">--</span>
					<a ng-if="checkFpmStatus == 2" href="javascript:void(0);" ng-click="checkFpm()">重新检测</a>
				</td>
				<td>
					<span ng-if="checkFpmStatus != 2">--</span>
					<span ng-if="checkFpmStatus == 2">安装配置 FPM</span>
				</td>
				<td>
					<span ng-if="checkFpmStatus != 2">--</span>
					<span ng-if="checkFpmStatus == 2">--</span>
				</td>
			</tr>
			<!-- fpm 环境 end -->

			<!-- 授权接入 start -->
			<tr ng-if="checkAccountStatus != 2">
				<td>授权接入账号</td>
				<td>
					<a href="#" ng-click="checkAuthAccount(true)" class="btn btn-primary">检测</a>
				</td>
				<td ng-if="checkAccountStatus === 0"><span class="color-gray wi wi-info-sign">检测中...</span></td>
				<td ng-if="checkAccountStatus == 1"><span class="color-green wi wi-right-sign">正确</span></td>
				<td ng-if="!checkAccountStatus && checkAccountStatus !== 0"><span>--</span></td>
				<td><div>--</div></td>
				<td>--</td>
				<td>--</td>
			</tr>
			<tr ng-repeat="account in errorAccounts">
				<td>{{ account.name }}</td>
				<td>--</td>
				<td  style="max-width:250px;"><i class="color-red wi wi-info-sign"></i>{{account.error}}</td>
				<td><a href="javascript:void(0);" ng-click="checkAuthAccount()">重新检测</a></td>
				<td>
					<a href="{{account_post_url}}acid={{account.acid}}&uniacid={{account.uniacid}}&account_type={{account.type}}" target="_blank">
					重新接入 {{ account.name }}
					</a>
				</td>
				<td>--</td>
			</tr>
			<!-- 授权接入 end -->

			<!-- 表损坏 start -->
			<div>
			<tr ng-if="wrong_tables == '' || checkMysqlTableStatus == 1 || checkMysqlTableStatus == 0">
				<td>表损坏</td>
				<td>
					<a href="#" ng-click="checkMysqlTable(true)" class="btn btn-primary">检测</a>
				</td>
				<td ng-if="checkMysqlTableStatus == 1"><span class="color-green wi wi-right-sign">正确</span></td>
				<td ng-if="checkMysqlTableStatus === 0"><span class="color-gray wi wi-info-sign">检测中...</span></td>
				<td ng-if="!checkMysqlTableStatus && checkMysqlTableStatus !== 0"><span>--</span></td>
				<td><div>--</div></td>
				<td>--</td>
				<td>--</td>
			</tr>

			<tr ng-repeat="wrong_table in wrong_tables">
				<td ng-bind="wrong_table.Table"></td>
				<td>--</td>
				<td><i class="color-red wi wi-info-sign"></i>错误</td>

				<td>
					<div>
					<a href="javascript:void(0);" ng-click="checkMysqlTable()">重新检测</a>
						<!--<a href="" target="_balnk">解决方案</a>-->
					</div>
				</td>

				<td>修复 {{ wrong_table.Table }} 表</td>
				<td> <a href="https://market.w7.cc/valueAddedServices" target="_balnk">查看</a> </td>
			</tr>
			</div>
			<!-- 表损坏 end -->
		</table>
	</div>
</div>

<script>
	angular.module('systemApp').value('config', {
		'check_num' : {$check_num},
		'check_wrong_num' : {$check_wrong_num},
		'system_check_items' : {php echo json_encode($system_check_items);},
		'links': {
			'account_post_url': "{php echo url('account/post')}",
			'check_table_link': "{php echo url('system/check/check_table')}",
			'check_fpm_link': "{php echo url('system/check/check_fpm')}",
			'check_auth_accounts': "{php echo url('system/check/check_auth_accounts')}",
			'check_system': "{php echo url('system/check')}",
		},
	});
	angular.bootstrap($('#js-system-check'), ['systemApp']);
</script>

{template 'common/footer'}