<?php include_once( "../../../../spider.inc.php" ); ?>
{template:admin_default.tpl}
{module:system.package.LoadList}
{module:system.package.install.Form}
{preset:page_title 'システム設定 >パッケージ管理 > インストール'}

	<div class="panc">
		<a href="../../../">管理パネルトップ</a>
		&gt; <a href="../../">システム設定</a>
		&gt; <a href="../">パッケージ管理</a>
		&gt; {if:system.package.install.target_package_object->isInstall()}設定変更{else}インストール{/if}
	</div>
	<h1>システム設定 &gt; パッケージ管理 &gt; パッケージ{if:system.package.install.target_package_object->isInstall()}設定変更{else}インストール{/if}</h1>
	
	{if:IS_ERROR}
		<ul class="error">
		{foreach:errors num error}
			<li>{write:error}</li>
		{/foreach}
		</ul>
	{else-if:count(system.package.install.install_object_hash)==0}
		<p>パッケージを指定してください。</p>
		<p style="text-align:center;">
			<input type="button" value="前のページに戻る" onclick="history.back();" style="font-size:16px;padding:6px;" />
		</p>
	{else}
	<div id="install-panel">
		<form name="mform" action="./confirm.php" method="post">
		<input type="hidden" name="system_install_package_id" value="{write:system.package.install.target_package_object->getPackageId()}" />
		{if:count(system.package.install.install_object_hash)>1}
		<p>未インストールの依存パッケージが見つかりました。<br />依存パッケージも同時にインストールします。</p>
		<p> 
			{foreach:system.package.install.install_object_hash packageObject}
				&nbsp;{write:packageObject->getPackageViewName()}
			{/foreach}
		</p>
		{else}
		<p>
			{write:system.package.install.target_package_object->getPackageViewName()}パッケージ{if:system.package.install.target_package_object->isInstall()}の設定を変更します。{else}をインストールします。{/if}
		</p>
		{/if}
		
		{foreach:system.package.install.install_object_hash packageObject}
		<div id="package-{write:packageObject->getPackageId()}-form" style="margin-bottom:1em;"></div>
		{/foreach}
		
		<br />
		<p style="text-align:center;">
			<input type="submit" value="{if:system.package.install.target_package_object->isInstall()}設定変更を続ける{else}インストールを続ける{/if}" style="font-size:16px;padding:6px;" />
		</p>
		</form>
	</div>
	
<script type="text/javascript"><!--
/**
 * インストールするパッケージの設定フォーム読み込み関連
 */
var systemPackageInstallHttpObject;
var systemPackageInstallPackageIdArray;
function systemPackageInstallGetInputForm( packageId ) {
	var targetUrl	= '../../../' + packageId + '/configuration/form.php?sitpi={write:get.sitpi}';
	systemPackageInstallHttpObject	= FormerCommon.createHttpRequest(systemPackageInstallGetInputFormResult);
	if( systemPackageInstallHttpObject ) {
		systemPackageInstallHttpObject.packageId	= packageId;
		systemPackageInstallHttpObject.open("GET",targetUrl,true);
		systemPackageInstallHttpObject.send(null);
	} else {
		alert('サーバー通信を開始できません!');
	}
}
function systemPackageInstallGetInputFormResult() {
	if ((systemPackageInstallHttpObject.readyState == 4) && (systemPackageInstallHttpObject.status == 200)){
		var targetDivId	= 'package-' + systemPackageInstallHttpObject.packageId + '-form';
		var resultPanel	= document.getElementById(targetDivId);
		if( resultPanel ) {
			resultPanel.innerHTML	= systemPackageInstallHttpObject.responseText;
		} else {
			alert('システムエラー');
		}
		if( systemPackageInstallPackageIdArray && systemPackageInstallPackageIdArray.length > 0 ) {
			var nextPackageId	= systemPackageInstallPackageIdArray.shift();
			systemPackageInstallGetInputForm( nextPackageId );
		} else {
			setTimeout(FormerCommon.displayWhiteIn, 100);
		}
	} else if ((systemPackageInstallHttpObject.readyState == 4) && (systemPackageInstallHttpObject.status != 200)){
		alert(systemPackageInstallHttpObject.packageId + 'パッケージの設定フォーム読み込み時にサーバー通信でエラーが発生しました。');
		if( systemPackageInstallPackageIdArray && systemPackageInstallPackageIdArray.length > 0 ) {
			var nextPackageId	= systemPackageInstallPackageIdArray.shift();
			systemPackageInstallGetInputForm( nextPackageId );
		} else {
			setTimeout(FormerCommon.displayWhiteIn, 100);
		}
	} else {
	}
}
/**
 * メール送信設定のオプションフォームを読み込む
 */
var systemPackageMailOptionHttpObjectArray;
function systemPackageMailOptionLoad( packageId, panelId, selectObject ) {
	var method		= selectObject.options[selectObject.selectedIndex].value;
	var targetUrl	= './mailform.php?sysmailpid=' + packageId + '&sysmailmtd=' + method;
	var httpObject	= FormerCommon.createHttpRequest(systemPackageMailOptionLoadResult);
	if( httpObject ) {
		httpObject.packageId	= packageId;
		httpObject.panelId		= panelId;
		httpObject.open("GET",targetUrl,true);
		systemPackageMailOptionHttpObjectArray.push(httpObject);
		if( systemPackageInstallPackageIdArray && systemPackageInstallPackageIdArray.length == 0 ) {
			FormerCommon.displayGrayOut(9999);
		}
		httpObject.send(null);
	} else {
		alert('サーバー通信を開始できません!');
	}
	
}
function systemPackageMailOptionLoadResult() {
	if( systemPackageMailOptionHttpObjectArray && systemPackageMailOptionHttpObjectArray.length > 0 ) {
		var httpObject	= systemPackageMailOptionHttpObjectArray.shift();
		if ((httpObject.readyState == 4) && (httpObject.status == 200)){
			var targetPanel	= document.getElementById(httpObject.panelId);
			if( targetPanel ) {
				targetPanel.innerHTML	= httpObject.responseText;
			} else {
			}
			if( systemPackageInstallPackageIdArray && systemPackageInstallPackageIdArray.length == 0
			&& systemPackageMailOptionHttpObjectArray && systemPackageMailOptionHttpObjectArray.length == 0 ) {
				setTimeout(FormerCommon.displayWhiteIn, 100);
			}
		} else if ((httpObject.readyState == 4) && (httpObject.status != 200)){
			alert('通信エラー');
		} else {
			systemPackageMailOptionHttpObjectArray.unshift(httpObject);
		}
	}
}
/**
 * ページ初期化
 */
function systemPackageInstallInit() {
	systemPackageInstallPackageIdArray		= new Array();
	systemPackageMailOptionHttpObjectArray	= new Array();
	{foreach:system.package.install.install_object_hash packageObject}
	systemPackageInstallPackageIdArray.push('{write:packageObject->getPackageId()}');
	{/foreach}
	if( systemPackageInstallPackageIdArray.length > 0 ) {
		var firstPackageId	= systemPackageInstallPackageIdArray.shift();
		systemPackageInstallGetInputForm( firstPackageId );
		FormerCommon.displayGrayOut(9999);
	}
}
if(window.attachEvent){
	window.attachEvent('onload',systemPackageInstallInit);
}else{
	window.addEventListener('DOMContentLoaded',systemPackageInstallInit,false);
}
//--></script>
	{/if}
<style type="text/css">
#install-panel table {
	border-collapse: collapse;
	border : solid 1px #808080;
}
#install-panel table thead tr th {
	border : solid 1px #808080;
	background-color : #c0c0c0;
	color : #606060;
	vertical-align: top;
	padding: 2px;
}
#install-panel table tbody tr th {
	border : solid 1px #808080;
	background-color : #c0c0c0;
	color : #606060;
	vertical-align: top;
	padding: 2px;
}
#install-panel table tbody tr td {
	border : solid 1px #808080;
	color : #606060;
	vertical-align: top;
	padding: 2px;
}
</style>