<%@ page import="com.atlassian.jira.util.BuildUtils,
                 com.atlassian.license.License,
                 com.atlassian.license.LicenseManager,
                 com.atlassian.jira.ManagerFactory,
                 com.atlassian.jira.web.action.util.JiraLicenseUtils"%>
<%@ taglib uri="webwork" prefix="webwork" %>
<%@ taglib uri="webwork" prefix="ui" %>
<%@ taglib uri="sitemesh-page" prefix="page" %>
<html>
<head>
<%--	<title>Setup Enterprise License </title>--%>
</head>

<body>

<webwork:if test="licenseUpdated == true">
    <page:applyDecorator name="jirapanel">
	    <page:param name="width">100%</page:param>
	    <page:param name="title">Update License</page:param>
        <page:param name="description">
            <font color=cc0000><b>Your license has been successfully updated. Please restart your server so that all necessary changes can take affect.
            <p>
            Changes will not take place until server is restarted.</b></font>
            <p>Click <a href="<%= request.getContextPath() %>/">here</a> when the server is restarted.
        </page:param>
    </page:applyDecorator>
</webwork:if>
<webwork:elseIf test="installationConfirmed == true">
    <page:applyDecorator name="jirapanel">
	    <page:param name="width">100%</page:param>
	    <page:param name="title">Update License</page:param>
        <page:param name="description">
            <font color=cc0000><b>The installation is complete. Please restart your server so that all necessary changes can take affect.
            <p>
            Changes will not take place until server is restarted.</b></font>
            <p>Click <a href="<%= request.getContextPath() %>/">here</a> when the server is restarted.
        </page:param>
    </page:applyDecorator>
</webwork:elseIf>
<webwork:else>
    <page:applyDecorator name="jiraform">
        <page:param name="action">ConfirmNewInstallationWithOldLicense.jspa</page:param>
        <page:param name="submitName">Proceed</page:param>
        <page:param name="width">100%</page:param>
        <page:param name="title">Confirm New Installation</page:param>
        <page:param name="description">
            JIRA licenses contain a period of upgrades and support.  Your support and upgrade period
            ended on <webwork:property value="/outlookDate/formatDMY(supportPeriodEnd)" />.
            <p>
            This version of JIRA (<%= BuildUtils.getVersion() %> - <font size="1">build #<%= BuildUtils.getCurrentBuildNumber() %></font>) was created on <%= ManagerFactory.getOutlookDateManager().getOutlookDate(request.getLocale()).formatDMY(BuildUtils.getCurrentBuildDate()) %>.
            As your current license is not valid for this version, your use of JIRA should be considered
            an evaluation.
            <p>
            Current license details:<br>
            <% License license = LicenseManager.getInstance().getLicense(JiraLicenseUtils.JIRA_LICENSE_KEY); %>
            <table class="borderedBox" bgcolor="fffff0">
                <tr><td><b>Organisation:</b>&nbsp;</td><td><%= license.getOrganisation() %></td></tr>
                <tr><td><b>License Type:</b>&nbsp;</td><td><%= license.getLicenseType() %></td></tr>
                <tr><td><b>Date Purchased:</b>&nbsp;</td><td><%= ManagerFactory.getOutlookDateManager().getOutlookDate(request.getLocale()).formatDMY(license.getDatePurchased()) %></td></tr>
            </table>
            <p>
            You can either:
            <dl>
                <dd>enter a new license below</dd>
                <dd><font color="red"><i>OR</i></font></dd>
                <dd>you can proceed with the current license under the <b>Evaluation Terms</b>, which means you will not be able to add any issues after 30 days.<dd>
            </dl>
            <p>
        </page:param>

        <ui:component label="'Admin User Name'" name="'userName'" template="userselect.jsp">
            <ui:param name="'formname'" value="'jiraform'" />
            <ui:param name="'imageName'" value="'userImage'"/>
            <ui:param name="'size'" value="40"/>
        </ui:component>

        <ui:component label="'Password'" name="'password'" template="password.jsp">
            <ui:param name="'size'">40</ui:param>
            <ui:param name="'description'">You must provide a valid Administrator username and password to proceed</ui:param>
        </ui:component>


        <tr>
            <td bgcolor="fffff0">&nbsp;</td>
            <td bgcolor="ffffff">&nbsp;</td>
        </tr>

        <tr>
            <td bgcolor="fffff0">&nbsp;</td>
            <td bgcolor="ffffff"><font color="red"><b>EITHER ENTER A LICENSE KEY</b></font></td>
        </tr>

        <page:param name="licenseString">Copy and paste the license key below.</page:param>

        <ui:component template="textlabel.jsp" label="text('admin.server.id')" value="/serverId"/>

        <ui:textarea label="'License'" name="'license'" cols="50" rows="10" >
            <ui:param name="'description'">
                <webwork:text name="'system.error.license.line1.desc'" /><br>
                <webwork:text name="'system.error.license.line2.desc'">
                    <webwork:param name="'value0'"><a target="_blank" href="<webwork:component name="'external.link.jira.license.view'" template="externallink.jsp" >
                    <webwork:param name="'value0'"><%= BuildUtils.getVersion() %></webwork:param>
                    <webwork:param name="'value1'"><%= BuildUtils.getCurrentBuildNumber() %></webwork:param>
                    <webwork:param name="'value2'"><%= BuildUtils.getEdition() %></webwork:param>
                    <webwork:param name="'value3'"><webwork:property value="/serverId"/></webwork:param>
                </webwork:component>"></webwork:param>
                    <webwork:param name="'value1'"></a></webwork:param>
                </webwork:text>
            </ui:param>
        </ui:textarea>


        <tr>
            <td bgcolor="fffff0">&nbsp;</td>
            <td bgcolor="ffffff"><font color="red"><b>OR CONFIRM NEW EVALUTION PERIOD</b></font></td>
        </tr>

        <ui:checkbox label="'Confirm'" name="'confirm'" fieldValue="'confirmed'" >
            <ui:param name="'description'">Check this box to agree to an extended evaluation period.</ui:param>

        </ui:checkbox>

    </page:applyDecorator>
</webwork:else>
</p>

</body>
</html>