# --
# AdminSelectBox.dtl - provides HTML form for SelectBox
# Copyright (C) 2001-2011 OTRS AG, http://otrs.org/
# --
# $Id: AdminSelectBox.dtl,v 1.11 2011/01/05 10:37:27 mg Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

<div class="MainBox ARIARoleMain LayoutFixedSidebar SidebarFirst">
    <h1>$Text{"SQL Box"}</h1>

    <div class="SidebarColumn">
        <div class="WidgetSimple">
            <div class="Header">
                <h2>$Text{"Hint"}</h2>
            </div>
            <div class="Content">
                <p class="FieldExplanation">
                    $Text{"Here you can enter SQL to send it directly to the application database."}
                </p>
            </div>
        </div>
    </div>

    <div class="ContentColumn">
        <div class="WidgetSimple">
            <div class="Header">
                <h2>$Text{"Options"}</h2>
            </div>
            <div class="Content">

                <form action="$Env{"CGIHandle"}" method="post" class="Validate" id="AdminSelectBoxForm">
                    <input type="hidden" name="Action" value="$Env{"Action"}"/>
                    <input type="hidden" name="Subaction" value="Select"/>
                    <fieldset class="TableLike FixedLabelSmall">

                        <label class="Mandatory" for="SQL"><span class="Marker">*</span> $Text{"SQL"}:</label>
                        <div class="Field">
                            <textarea name="SQL" id="SQL" rows="3" class="W100pc Validate_Required $QData{"SQLInvalid"}">$QData{"SQL"}</textarea>
                            <div id="SQLError" class="TooltipErrorMessage"><p>$Text{"This field is required."}</p></div>
                            <div id="SQLServerError" class="TooltipErrorMessage">
                                <p>
<!-- dtl:block:FieldRequiredServerError -->
                                    $Text{"This field is required."}
<!-- dtl:block:FieldRequiredServerError -->
<!-- dtl:block:SQLSyntaxServerError -->
                                    $Text{"The syntax of your SQL query has a mistake. Please check it."}
<!-- dtl:block:SQLSyntaxServerError -->
<!-- dtl:block:BindParamServerError -->
                                    $Text{"There is at least one parameter missing for the binding. Please check it."}
<!-- dtl:block:BindParamServerError -->
                                </p>
                            </div>
                        </div>
                        <div class="Clear"></div>

                        <label for="Max">$Text{"Limit"}:</label>
                        <div class="Field">
                            <input type="text" name="Max" id="Max" value="$QData{"Max"}" class="W50px" />
                        </div>
                        <div class="Clear"></div>

                        <label for="ResultFormat">$Text{"Result format"}:</label>
                        <div class="Field">
                            $Data{"ResultFormatStrg"}
                        </div>
                        <div class="Clear"></div>

                        <div class="Field SpacingTop">
                            <button class="Primary" type="submit" id="Run" value="$Text{"Run Query"}">$Text{"Run Query"}</button>
                        </div>
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
Core.Form.Validate.SetSubmitFunction($('#AdminSelectBoxForm'), function (Form) {
    Form.submit();

    if ($('#ResultFormat option:selected').text() != 'CSV') {
        window.setTimeout(function(){
            Core.Form.DisableForm( $(Form) );
        }, 0);
    }
});
//]]></script>
<!--dtl:js_on_document_complete-->
                    </fieldset>
                </form>
            </div>
        </div>

<!-- dtl:block:Result -->
        <div class="WidgetSimple">
            <div class="Header">
                <h2>$Text{"Results"}</h2>
            </div>
            <div class="Content">
<!-- dtl:block:NoMatches -->
                <p>$Text{"No matches found."}</p>
<!-- dtl:block:NoMatches -->
<!-- dtl:block:ResultTableStart -->
                <table class="DataTable">
                    <tbody>
<!-- dtl:block:ResultTableStart -->
<!-- dtl:block:Row -->
                        <tr>
<!-- dtl:block:Cell -->
                            <td title="$QData{"Content", "80"}">$QData{"Content", "12"}</td>
<!-- dtl:block:Cell -->
                        </tr>
<!-- dtl:block:Row -->
<!-- dtl:block:ResultTableEnd -->
                    </tbody>
                </table>
<!-- dtl:block:ResultTableEnd -->
            </div>
        </div>
<!-- dtl:block:Result -->
    </div>
    <div class="Clear"></div>
</div>
