# --
# AgentLinkObject.dtl - provides HTML for AgentLinkObject mask
# Copyright (C) 2001-2012 OTRS AG, http://otrs.org/
# --
# $Id: AgentLinkObject.dtl,v 1.59 2012/11/20 15:18:29 mh 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.
# --

<!-- dtl:block:Link -->
<div class="LayoutPopup ARIARoleMain">

    <div class="Header">
        <h1>
            $Text{"Link Object: %s", "$Data{"SourceObjectLong"}"}
        </h1>
        <p>
            <a href="$Env{"Baselink"}Action=$Env{"Action"};Subaction=Close" id="CloseLink">$Text{"Close window"}</a>

<!-- dtl:block:TemporaryLink -->
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    $('#CloseLink').bind('click', function (Event) {
        window.close();
        return false;
    });
//]]></script>
<!--dtl:js_on_document_complete-->
<!-- dtl:block:TemporaryLink -->

<!-- dtl:block:LinkMenuDelete -->
            $Text{"or"}
            <a href="$Env{"Baselink"}Action=$Env{"Action"};Subaction=LinkDelete;Mode=$LQData{"Mode"};SourceObject=$LQData{"SourceObject"};SourceKey=$LQData{"SourceKey"};TargetIdentifier=$LQData{"TargetIdentifier"}">
                $Text{"go to link delete screen"}
            </a>
<!-- dtl:block:LinkMenuDelete -->

        </p>
    </div>

    <div class="Content">
        <form action="$Env{"CGIHandle"}" method="post" name="compose" id="LinkSearchForm">
            <input type="hidden" name="Action" value="$Env{"Action"}" />
            <input type="hidden" name="Mode" value="$QData{"Mode"}" />
            <input type="hidden" name="SourceObject" value="$QData{"SourceObject"}" />
            <input type="hidden" name="SourceKey" value="$QData{"SourceKey"}" />

            <div class="WidgetSimple">
                <div class="Header">
                    <h2>$Text{"Select Target Object"}</h2>
                </div>
                <div class="Content">
                    <fieldset class="TableLike">
                        <label for="TargetIdentifier">
                            $Text{"Link Object"} $QData{"SourceObjectNormal"} $Text{"with"}:
                        </label>
                        <div class="Field">
                            $Data{"TargetObjectStrg"}
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    $('#TargetIdentifier').bind('change', function (Event) {
        $('#SubmitSelect').addClass('gotclicked');
        $(this).closest('form').submit();
    });
    // Two submits in this form
    // if SubmitSelect button was clicked,
    // add "gotclicked" class to this button
    $('#SubmitSelect').bind('click.Submit', function () {
       $('#SubmitSelect').addClass('gotclicked');
    });

    $('#LinkSearchForm').submit(function () {
        // If SubmitSelect button was clicked,
        // "gotclicked" was added as class to the button
        // remove the class and do the search
        if ( $('#SubmitSelect').hasClass('gotclicked') ) {
            $('#SubmitSelect').removeClass('gotclicked');
            return true;
        }

        var SearchValueFlag = false;
        $('#LinkSearchForm input, #LinkSearchForm select').each(function () {
            if ( $(this).attr('name') && $(this).attr('name').match(/^SEARCH\:\:/) ) {
                if ( $(this).val() && $(this).val() !== '' ) {
                    SearchValueFlag = true;
                }
            }
        });

        if ( !SearchValueFlag ) {
           alert(Core.Config.Get('EmptySearchMsg'));
           return false;
        }
    });
//]]></script>
<!--dtl:js_on_document_complete-->
                            <button type="submit" id="SubmitSelect" name="SubmitSelect" value="$Text{"Select"}">$Text{"Select"}</button>
                        </div>
                    </fieldset>
                </div>
            </div>

            <div class="WidgetSimple">
                <div class="Header">
                    <h2>$Text{"Search"} $QData{"TargetRealname"}</h2>
                </div>
                <div class="Content">
                    <fieldset class="TableLike FixedLabel">
<!-- dtl:block:LinkSearchRow -->
                        <label>
                            $Text{"$Data{"Name"}"}:
                        </label>
                        <div class="Field">
                            $Data{"InputStrg"}
                        </div>
<!-- dtl:block:LinkSearchRow -->
                        <div class="Field">
                            <button type="submit" id="SubmitSearch" name="SubmitSearch" value="$Text{"Search"}">$Text{"Search"}</button>
                        </div>
                    </fieldset>
                </div>
            </div>

<!-- dtl:block:LinkTableComplex -->
            $Data{"LinkTableStrg"}
<!-- dtl:block:LinkTableComplex -->
        </form>
    </div>
</div>
<!-- dtl:block:Link -->

<!-- dtl:block:Delete -->
<div class="LayoutPopup ARIARoleMain">

    <div class="Header">
        <h1>
            $Text{"Unlink Object: %s", "$QData{"SourceObjectNormal"}"}
        </h1>
        <p>
            <a href="$Env{"Baselink"}Action=$Env{"Action"};Subaction=Close">$Text{"Close window"}</a>
            $Text{"or"}
            <a href="$Env{"Baselink"}Action=$Env{"Action"};Mode=$LQData{"Mode"};SourceObject=$LQData{"SourceObject"};SourceKey=$LQData{"SourceKey"};TargetIdentifier=$LQData{"TargetIdentifier"}" class="menuitem">
                $Text{"go to link add screen"}
            </a>
        </p>
    </div>
    <div class="Content">
        <h2>$Text{"Select Target Object"}</h2>
        <form action="$Env{"CGIHandle"}" method="get">
            <input type="hidden" name="Action" value="$Env{"Action"}" />
            <input type="hidden" name="Subaction" value="LinkDelete" />
            <input type="hidden" name="Mode" value="$QData{"Mode"}" />
            <input type="hidden" name="SourceObject" value="$QData{"SourceObject"}" />
            <input type="hidden" name="SourceKey" value="$QData{"SourceKey"}" />
            <input type="hidden" name="TargetIdentifier" value="$QData{"TargetIdentifier"}" />
<!-- dtl:block:DeleteTableComplex -->
            $Data{"LinkTableStrg"}
<!-- dtl:block:DeleteTableComplex -->
        </form>
    </div>
</div>
<!-- dtl:block:Delete -->
