<!--
Available request parameters:
"isUpdateReport"       (boolean) ALWAYS FALSE Right-click report
"idReport"             (long)    NEVER USED   Right-click report
Specific R26:
"dataValues"           (String)  MANDATORY    UID of an ItemRevision
-->

<%@ page import="com.capgemini.framework.common.SettingsHelper" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.util.Calendar" %>
<%@ page import="java.text.SimpleDateFormat" %>

<%
    Date startDate = Calendar.getInstance().getTime();
    SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");

    String revisionRule = SettingsHelper.getPropertyWithDefaultValue("common.bom.revisionRule.REPORT_R26", SettingsHelper.getDefaultRevisionRule());
    String date         = sdf.format(startDate);
%>

<script src="/kurt-web/js/obtain_data.js"></script>

<!-- HTML, will probably be imported right inside a form -->
<table cellspacing="0" cellpadding="3" border="0">
    <tr>
        <td class="tdFieldTitle required">Composant* :</td>
        <td>
            <input type="text" id="component" name="component" value="" readonly />
        </td>
    </tr>
    <tr>
        <td class="tdFieldTitle">R&egrave;gle de r&eacute;vision :</td>
        <td>
            <input type="text" id="revision_rule" name="revision_rule" value="<%= revisionRule %>" readonly />
        </td>
    </tr>
    <tr>
        <td class="tdFieldTitle">Date d'effectivit&eacute; :</td>
        <td>
            <input type="text" id="datepicker" name="datepicker" value="<%= date %>" readonly />
        </td>
    </tr>
    <tr>
        <td class="tdFieldTitle" colspan="2" style="text-align:center;">
            <br/>
            <div id="loading" style="display:none;">
                <i>Traitement en cours...</i>
                <br/>
                <img src="/kurt-web/ihm/progress.gif" vspace="6" width="129" height="20">
            </div>
        </td>
    </tr>
</table>

<script>
    /* Run asynchronous AJAX query for loading input content */
    setTimeout("ObtainData('/kurt-web/report_r26/obtainDataR26?dataValues=" + parseURL("dataValues", "") + "')",100);
</script>

<!-- Internal functional Javascript methods (checks etc.) -->
<script>
    /* Automatic checks before sending the form */
    function checkForm() {
        var isCheckOk = false;
        if (isMandatoryFieldEmpty("component")){
            parent.Dialog("Erreur", "Veuillez saisir le champ obligatoire : Composant.");
        }else{
            isCheckOk = true;
        }
        return isCheckOk;
    }

    /* Retrieve data for filling current form */
    function ServerResponseForObtainData() {
        if (objGetRequest.readyState == 4) {
            if (objGetRequest.status == 200) {
                var queryResponse = JSON.parse(objGetRequest.responseText);
                if (queryResponse.success){
                    document.getElementById("component").value= queryResponse.ObjectId;
                }else{
                    parent.Dialog("Erreur",queryResponse.error);
                    document.getElementById("submitButton").style.display = 'none';
                }
            }else{
                parent.Dialog("Erreur","La connexion avec le site semble interrompue.");
            }

            /* Display buttons and hide loading bar */
            document.getElementById("loading").style.display = 'none';
            document.getElementById("btZone").style.display = '';
        }
    }
</script>