# --
# AdminGenericInterfaceInvokerDefault.dtl - provides HTML form for AdminLog
# Copyright (C) 2001-2011 OTRS AG, http://otrs.org/
# --
# $Id: AdminGenericInterfaceInvokerDefault.dtl,v 1.11 2011/12/13 22:58:14 mb 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 AdminGenericInterfaceInvokerDefault">
<!-- dtl:block:TitleAdd -->
    <h1>$Text{"Add new Invoker to Web Service %s", "$Data{"WebserviceName"}"}</h1>
<!-- dtl:block:TitleAdd -->
<!-- dtl:block:TitleChange -->
    <h1>$Text{"Change Invoker %s of Web Service %s", "$Data{"Invoker"}", "$Data{"WebserviceName"}"}</h1>
<!-- dtl:block:TitleChange -->
<!-- breadcrumb -->
    <div class="GenericInterfaceWebserviceConfigPath">
        <h3>
            $Config{"GenericInterface::Webservice::Path::Separator"}
            <a href="$Env{"Baselink"}Action=AdminGenericInterfaceWebservice">$Text{"Web Services"}</a>

            $Config{"GenericInterface::Webservice::Path::Separator"}
            <a href="$Env{"Baselink"}Action=AdminGenericInterfaceWebservice;Subaction=Change;WebserviceID=$QData{"WebserviceID"}">$QData{"WebserviceName"}</a>

            $Config{"GenericInterface::Webservice::Path::Separator"}
<!-- dtl:block:NavigationAdd -->
            $Text{"Add new invoker"}
<!-- dtl:block:NavigationAdd -->
<!-- dtl:block:NavigationChange -->
            $Text{"Change invoker %s", "$Data{"Invoker"}"}
<!-- dtl:block:NavigationChange -->
        </h3>
    </div>

    <div class="SidebarColumn">
        <div class="WidgetSimple">
            <div class="Header">
                <h2>$Text{"Actions"}</h2>
            </div>
            <div class="Content">
                <ul class="ActionList">
                    <li>
                        <a href="$Env{"Baselink"}Action=AdminGenericInterfaceWebservice;Subaction=Change;WebserviceID=$LQData{"WebserviceID"}" class="CallForAction"><span>$Text{"Go back to web service"}</span></a>
                    </li>
<!-- dtl:block:ActionListDelete -->
                    <li>
                        <button class="CallForAction Trash W75pc" type="button" id="DeleteButton"><span>$Text{"Delete"}</span></button>
                        <div class="Hidden" id="DeleteDialogContainer">
                            <span class="WarningDialog ">&nbsp;</span>
                            <p id="DeleteDialog" class="Center Warning">
                                $Text{"Do you really want to delete this invoker?"}
                            </p>
                            <p class="Center Warning">
                                $Text{"All configuration data will be lost."}
                            </p>
                            <div class="SpacingTop"></div>
                        </div>
                    </li>
<!-- dtl:block:ActionListDelete -->
                </ul>
            </div>
        </div>
    </div>
    <div class="ContentColumn">

        <div class="WidgetSimple">
            <div class="Header">
                <h2>$Text{"Invoker Details"}</h2>
            </div>
            <div class="Content">
                <form action="$Env{"CGIHandle"}" class="Validate" method="post">
                    <input type="hidden" name="Action" value="AdminGenericInterfaceInvokerDefault" />
                    <input type="hidden" name="Subaction" value="$QData{"Mode"}Action" />
                    <input type="hidden" name="WebserviceID" value="$QData{"WebserviceID"}" id="WebserviceID" />
                    <input type="hidden" name="InvokerType" value="$QData{"InvokerType"}" />

                    <fieldset class="TableLike">
                        <label for="Invoker" class="Mandatory">
                            <span class="Marker">*</span>
                            $Text{"Name"}:
                        </label>
                        <div class="Field">
                            <input type="text" class="W50pc RegisterChange Validate_Required $QData{"InvokerServerError"}" maxlength="200" id="Invoker" name="Invoker" value="$QData{"Invoker"}" />
                            <input type="hidden" id="OldInvoker" name="OldInvoker" value="$QData{"Invoker"}" />
                            <p class="FieldExplanation">
                                $Text{"The name is typically used to call up an operation of a remote web service."}
                            </p>
                            <div id="InvokerError" class="TooltipErrorMessage">
                                $Text{"This field is required."} $Text{"Please provide a unique name for this web service invoker."}
                            </div>
                            <div id="InvokerServerError" class="TooltipErrorMessage">
                                $Text{"The name you entered already exists."}
                            </div>
                        </div>
                        <div class="Clear"></div>

                        <label for="Description">
                            $Text{"Description"}:
                        </label>
                        <div class="Field">
                            <input type="text" class="W50pc RegisterChange" maxlength="200" id="Description" name="Description" value="$QData{"Description"}" />
                        </div>
                        <div class="Clear"></div>

                        <label for="InvokerTypeDisplay">$Text{"Invoker backend"}:</label>
                        <div class="Field">
                            <input type="text" readonly="readonly" class="W50pc" id="InvokerTypeDisplay" value="$QData{"InvokerType"}" />
                            <p class="FieldExplanation">
                                $Text{"This OTRS invoker backend module will be called to prepare the data to be sent to the remote system, and to process its response data."}
                            </p>
                        </div>
                        <div class="Clear"></div>

                        <label for="MappingOutbound">$Text{"Mapping for outgoing request data"}:</label>
                        <div class="Field">
                            $Data{"MappingOutboundStrg"}
                            <input type="hidden" id="MappingOutboundConfigDialog" value="$QData{"MappingOutboundConfigDialog"}" />
<!-- dtl:block:MappingOutboundConfigureButton -->
                            <button type="button" class="HideOnChange" id="MappingOutboundConfigureButton" value="$Text{"Configure"}">$Text{"Configure"}</button>
<!-- dtl:js_on_document_complete -->
<script type="text/javascript">//<![CDATA[
$('#MappingOutboundConfigureButton').bind('click', function(){
    var URL;

    if ($('#MappingOutboundConfigDialog').val()) {
        URL = Core.Config.Get('Baselink') + 'Action=' + $('#MappingOutboundConfigDialog').val();
        URL += ';Subaction=Change;Invoker=' + $('#OldInvoker').val() + ';Direction=MappingOutbound' + ';WebserviceID=' + $('#WebserviceID').val();
        window.location.href = URL;
    }
});
//]]></script>
<!-- dtl:js_on_document_complete -->
<!-- dtl:block:MappingOutboundConfigureButton -->
                            <p class="FieldExplanation">
                                $Text{"The data from the invoker of OTRS will be processed by this mapping, to transform it to the kind of data the remote system expects."}
                            </p>
                        </div>
                        <div class="Clear"></div>

                        <label for="MappingInbound">$Text{"Mapping for incoming response data"}:</label>
                        <div class="Field">
                            $Data{"MappingInboundStrg"}
                            <input type="hidden" id="MappingInboundConfigDialog" value="$QData{"MappingInboundConfigDialog"}" />
<!-- dtl:block:MappingInboundConfigureButton -->
                            <button type="button" class="HideOnChange" id="MappingInboundConfigureButton" value="$Text{"Configure"}">$Text{"Configure"}</button>
<!-- dtl:js_on_document_complete -->
<script type="text/javascript">//<![CDATA[
$('#MappingInboundConfigureButton').bind('click', function(){
    var URL;

    if ($('#MappingInboundConfigDialog').val()) {
        URL = Core.Config.Get('Baselink') + 'Action=' + $('#MappingInboundConfigDialog').val();
        URL += ';Subaction=Change;Invoker=' + $('#OldInvoker').val() + ';Direction=MappingInbound' + ';WebserviceID=' + $('#WebserviceID').val();
        window.location.href = URL;
    }
});
//]]></script>
<!-- dtl:js_on_document_complete -->
<!-- dtl:block:MappingInboundConfigureButton -->
                            <p class="FieldExplanation">
                                $Text{"The response data will be processed by this mapping, to transform it to the kind of data the invoker of OTRS expects."}
                            </p>
                        </div>
                        <div class="Clear"></div>

                        <label for="EventsTable">$Text{"Event Triggers"}:</label>
                        <div class="Field W50pc">
                            <table class="DataTable W50pc" id="EventsTable" summary="List of all configured events">
                                <thead>
                                    <tr>
                                        <th>$Text{"Event"}</th>
                                        <th>$Text{"Asynchronous"}</th>
                                        <th>$Text{"Delete"}</th>
                                    </tr>
                                </thead>
                                <tbody>
<!-- dtl:block:NoDataFoundMsg -->
                                    <tr>
                                        <td colspan="4">
                                            $Text{"No data found."}
                                        </td>
                                    </tr>
<!-- dtl:block:NoDataFoundMsg -->

<!-- dtl:block:EventRow -->
                                    <tr>
                                        <td class="AsBlock">$QData{"Event"}</td>
                                        <td>$QData{"Asynchronous"}</td>
                                        <td class="Center">
                                            <a id="DeleteEvent$QData{"Event"}" class="TrashCan DeleteEvent" href="#" title="$Text{"Delete this event"}">
                                                $Text{"Delete this event"}
                                            </a>
                                        </td>
                                    </tr>
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    Core.Agent.Admin.GenericInterfaceInvoker.BindDeleteEventDialog({
        ElementID:                  'DeleteEvent$QData{"Event"}',
        EventName:                  '$QData{"Event"}',
        ElementSelector:            '#DeleteEvent$QData{"Event"}'
    });
//]]></script>
<!--dtl:js_on_document_complete-->
<!-- dtl:block:EventRow -->
                                </tbody>
                            </table>
                            <p class="FieldExplanation">
                                $Text{"This invoker will be triggered by the configured events."}
                            </p>
                        </div>

                        <div class="Hidden" id="DeleteEventDialogContainer">
                            <div id ="DeleteEventDialog" class="InnerContent GenericInterfaceDialog">
                                <span class="WarningDialog ">&nbsp;</span>
                                <p class="Center Warning">$Text{"Do you really want to delete this event trigger?"}</p>
                                <div class="SpacingTop"></div>
                            </div>
                        </div>

                        <div class="SpacingTop"></div>
                        <label class="HideOnChange" for="EventType">$Text{"Add Event Trigger"}:</label>
                        <div class="Field HideOnChange">
                            $Data{"EventTypeStrg"}
<!-- dtl:block:EventAdd -->
                            $Data{"EventStrg"}
<!-- dtl:block:EventAdd -->
                            <input type="checkbox" id="Asynchronous" checked="checked" class="GenericInterfaceSpacing" name="Asynchronous"/><span>Asynchronous</span>
                            <button type="button" id="AddEvent" class="Add GenericInterfaceSpacing" name="AddEvent" value="Add Event">Add Event</button>
                            <p class="FieldExplanation">
                                $Text{"To add a new event select the event object and event name and click on the "+" button"}.
                            </p>
                            <p class="FieldExplanation">
                                $Text{"Asynchronous event triggers are handled by the OTRS Scheduler in background (recommended)."}
                                <br/>
                                $Text{"Synchronous event triggers would be processed directly during the web request."}
                            </p>
                        </div>
                        <div class="Clear"></div>

                        <div class="Field SpacingTop">
                            <button type="submit" class="Primary" value="$Text{"Save and continue"}">$Text{"Save"}</button>
<!-- dtl:block:SaveAndFinishButton -->
                            <button type="submit" id="SaveAndFinishButton" value="$Text{"Save and finish"}">$Text{"Save and finish"}</button>
                            <input type="hidden" name="ReturnToWebservice" id="ReturnToWebservice" value="" />
<!-- dtl:js_on_document_complete -->
<script type="text/javascript">//<![CDATA[
$('#SaveAndFinishButton').bind('click', function(){
    $('#ReturnToWebservice').val(1);
});
//]]></script>
<!-- dtl:js_on_document_complete -->
<!-- dtl:block:SaveAndFinishButton -->
                            $Text{"or"}
                            <a href="$Env{"Baselink"}Action=AdminGenericInterfaceWebservice;Subaction=Change;WebserviceID=$QData{"WebserviceID"}">$Text{"Cancel"}</a>
                        </div>
                        <div class="Clear"></div>
                    </fieldset>
                </form>
            </div>
        </div>
    </div>
    <div class="Clear"></div>
</div>

<!-- dtl:js_on_document_complete -->
<script type="text/javascript">//<![CDATA[
Core.Agent.Admin.GenericInterfaceInvoker.Init({
    WebserviceID: $QData{"WebserviceID"},
    Invoker: "$QData{"Invoker"}",
    Action: 'AdminGenericInterfaceInvokerDefault',
    EventTypeSelected: $('#EventType').val(),
    Localization: {
        CommunicationErrorMsg: '$JSText{"An error occurred during communication."}',
        DeleteInvokerMsg: '$JSText{"Delete this Invoker"}',
        DeleteEventMsg: '$JSText{"Delete this Event Trigger"}',
        DeleteMsg: '$JSText{"Delete"}',
        CancelMsg: '$JSText{"Cancel"}'
    }
});

$('.RegisterChange').bind('change.RegisterChange keyup.RegisterChange', function (Event) {
    $('.HideOnChange').hide();
    $('.ShowOnChange').show();
});

$('#DeleteButton').bind('click', Core.Agent.Admin.GenericInterfaceInvoker.ShowDeleteDialog);

$('#EventType').bind('change', function (){
    Core.Agent.Admin.GenericInterfaceInvoker.ToogleEventSelect($(this).val());
});

$('#AddEvent').bind('click', function (){
    Core.Agent.Admin.GenericInterfaceInvoker.AddEvent( $('#EventType').val() );
});

//]]></script>


<!-- dtl:js_on_document_complete -->
