# --
# AgentTicketPhone.dtl - provides HTML form for phone
# Copyright (C) 2001-2013 OTRS AG, http://otrs.org/
# --
# $Id: AgentTicketPhone.dtl,v 1.153 2013/01/14 14:03:05 mn 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.
# --

$Include{"AgentCustomerSearch"}
<div class="MainBox ARIARoleMain">

    <h1>$Text{"Create New Phone Ticket"}</h1>

    <div class="LayoutFixedSidebar SidebarLast">
<!-- dtl:block:CustomerTable -->
        <div id="CustomerInfo" class="SidebarColumn WidgetSimple">
            <div class="Header">
                <h2>$Text{"Customer Information"}</h2>
            </div>
            <div class="Content">
                $Data{"CustomerTable"}
            </div>
        </div>
<!-- dtl:block:CustomerTable -->

        <div class="ContentColumn">
            <form action="$Env{"CGIHandle"}" method="post" enctype="multipart/form-data" name="compose" id="NewPhoneTicket" class="Validate PreventMultipleSubmits">
                <input type="hidden" name="Action" value="$Env{"Action"}"/>
                <input type="hidden" name="Subaction" value="StoreNew"/>
                <input type="hidden" name="FormID" value="$QData{"FormID"}"/>
                <input type="hidden" name="ExpandCustomerName" id="ExpandCustomerName" value="0"/>
                <input type="hidden" name="OwnerAll" id="OwnerAll" value="$QData{"OwnerAll"}"/>
                <input type="hidden" name="ResponsibleAll" id="ResponsibleAll" value="$QData{"ResponsibleAll"}"/>
                <input type="hidden" name="PreSelectedCustomerUser" id="PreSelectedCustomerUser" value=""/>
                <input type="hidden" name="SelectedCustomerUser" id="SelectedCustomerUser" value="$QData{"CustomerUser"}"/>
                <input type="hidden" name="TicketID" value="$QData{"TicketID"}"/>
                <input type="hidden" name="LinkTicketID" value="$QData{"LinkTicketID"}"/>

                <fieldset class="TableLike">

# example template for customizations, see hidden form at the end of the file
#                    <label>$Text{"Templates"}:</label>
#                    <div class="Field">
#                        <button type="button" onclick="$('#Template1').submit()" value="$Text{"Example Template"}">$Text{"Example Template"}</button>
#                    </div>
#                    <div class="Clear"></div>
<!-- dtl:block:TicketType -->
                    <label class="Mandatory" for="TypeID"><span class="Marker">*</span> $Text{"Type"}:</label>
                    <div class="Field">
                        $Data{"TypeStrg"}
                        <div id="TypeIDError" class="TooltipErrorMessage"><p>$Text{"This field is required."}</p></div>
                        <div id="TypeIDServerError" class="TooltipErrorMessage"><p>$Text{"This field is required."}</p></div>
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    $('#TypeID').bind('change', function (Event) {
        Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'TypeID', ['Dest', 'NewUserID', 'NewResponsibleID', 'NextStateID', 'PriorityID', 'ServiceID', 'SLAID', 'SignKeyID', 'CryptKeyID', $Data{"DynamicFieldNamesStrg"}, 'To', 'Cc', 'Bcc']);
    });
//]]></script>
<!--dtl:js_on_document_complete-->
                    </div>
                    <div class="Clear"></div>
<!-- dtl:block:TicketType -->


                    <div class="Field $QData{"CustomerHiddenContainer"}">
                        <div class="CustomerTicketTemplateFromCustomer SpacingTopSmall Hidden">
                            <input name="CustomerSelected" id="CustomerSelected" class="CustomerTicketRadio" type="radio" value=""/>
                            <input name="CustomerKey" id="CustomerKey" class="CustomerKey" type="hidden" value=""/>
                            <input class="CustomerTicketText W75pc" name="CustomerTicketText" id="CustomerTicketText" type="text" value="" readonly="readonly" />
                            <button type="button" id="RemoveCustomerTicket" class="Remove CustomerTicketRemove" value="$Text{"Remove Ticket Customer"}">$Text{"Remove Ticket Customer"}</button>
                        </div>

                        <div id="TicketCustomerContentFromCustomer" class="CustomerContainer">
<!-- dtl:block:MultipleCustomer -->
                            <div class="SpacingTopSmall ">
                                <input name="CustomerSelected" id="CustomerSelected" class="CustomerTicketRadio" type="radio" value="$QData{"Count"}" $QData{"CustomerSelected"}  $QData{"CustomerDisabled"} />
                                <input name="CustomerKey_$QData{"Count"}" id="CustomerKey_$QData{"Count"}" class="CustomerKey" type="hidden" value="$QData{"CustomerKey"}"/>
                                <input class="CustomerTicketText W75pc $QData{"CustomerError"}" name="CustomerTicketText_$Data{"Count"}" id="CustomerTicketText_$Data{"Count"}" type="text" value="$QData{"CustomerElement"}" readonly="readonly" />
                                <button type="button" id="RemoveCustomerTicket_$Data{"Count"}" class="Remove CustomerTicketRemove" value="$Text{"Remove Ticket Customer"}">$Text{"Remove Ticket Customer"}</button>

<!-- dtl:block:CustomerErrorExplantion -->
                                <p class="Explanation Error">$Text{"Please remove this entry and enter a new one with the correct value."}</p>
<!-- dtl:block:CustomerErrorExplantion -->

                                <div id="CustomerTicketText_$Data{"Count"}ServerError" class="TooltipErrorMessage">
<!-- dtl:block:CustomerGenericServerErrorMsg -->
                                    <p>$Text{"This field is required."}</p>
<!-- dtl:block:CustomerGenericServerErrorMsg -->
<!-- dtl:block:InvalidConfigServerErrorMsg -->
                                    <p>$Text{"This email address is not allowed due to the system configuration."}</p>
<!-- dtl:block:InvalidConfigServerErrorMsg -->
<!-- dtl:block:InvalidMXServerErrorMsg -->
                                    <p>$Text{"This email address failed MX check."}</p>
<!-- dtl:block:InvalidMXServerErrorMsg -->
<!-- dtl:block:InvalidDNSServerErrorMsg -->
                                    <p>$Text{"DNS problem, please check your configuration and the error log."}</p>
<!-- dtl:block:InvalidDNSServerErrorMsg -->
<!-- dtl:block:InvalidSyntaxServerErrorMsg -->
                                    <p>$Text{"The syntax of this email address is incorrect."}</p>
<!-- dtl:block:InvalidSyntaxServerErrorMsg -->
<!-- dtl:block:IsDuplicatedServerErrorMsg -->
                                    <p>$Text{"This address already exists on the address list."}</p>
<!-- dtl:block:IsDuplicatedServerErrorMsg -->
                                </div>
                            </div>
<!-- dtl:block:MultipleCustomer -->

                        </div>
<!-- dtl:block:MultipleCustomerCounter -->
                        <input name="CustomerTicketCounterFromCustomer" id="CustomerTicketCounterFromCustomer" type="hidden" value="$QData{"CustomerCounter"}"/>
<!-- dtl:block:MultipleCustomerCounter -->
                    </div>
                    <div class="Clear"></div>
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    $('.CustomerTicketRadio').bind('change', function () {
        var CustomerKey;
        if ( $(this).attr('checked') ){

            CustomerKey = $( '#CustomerKey_' +$(this).val() ).val();
            // get customer tickets
            Core.Agent.CustomerSearch.ReloadCustomerInfo(CustomerKey);
        }
        return false;
    });

    $('.CustomerTicketRemove').bind('click', function () {
        Core.Agent.CustomerSearch.RemoveCustomerTicket( $(this) );
        return false;
    });
//]]></script>
<!--dtl:js_on_document_complete-->

                    <label for="FromCustomer" class="Mandatory"><span class="Marker">*</span>$Text{"From customer"}:</label>
                    <div class="Field">
                        <input id="FromCustomer" type="text" name="FromCustomer" value="" class="CustomerAutoComplete W75pc $QData{"FromInvalid"}" autocomplete="off" />
                        <div id="FromCustomerServerError" class="TooltipErrorMessage">
<!-- dtl:block:FromServerErrorMsg -->
                            <p>$Text{"Please include at least one customer for the ticket."}</p>
<!-- dtl:block:FromServerErrorMsg -->
                        </div>
                    </div>
                    <div class="Clear"></div>

<!-- dtl:block:FromExternalCustomer -->
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    Core.Agent.CustomerSearch.AddTicketCustomer( 'FromCustomer', "$QData{"Email"}", "$QData{"Customer"}", true );
//]]></script>
<!--dtl:js_on_document_complete-->
<!-- dtl:block:FromExternalCustomer -->

                    <label class="Mandatory" for="Dest"><span class="Marker">*</span> $Text{"To queue"}:</label>
                    <div class="Field">
                        $Data{"ToStrg"}
                        <div id="DestError" class="TooltipErrorMessage" ><p>$Text{"This field is required."}</p></div>
                        <div id="DestServerError" class="TooltipErrorMessage"><p>$Text{"This field is required."}</p></div>
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    $('#Dest').bind('change', function (Event) {
        Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'Dest', ['TypeID', 'NewUserID', 'NewResponsibleID', 'NextStateID', 'PriorityID', 'ServiceID', 'SLAID', 'SignKeyID', 'CryptKeyID', $Data{"DynamicFieldNamesStrg"}, 'To', 'Cc', 'Bcc']);
    });
//]]></script>
<!--dtl:js_on_document_complete-->
                    </div>
                    <div class="Clear"></div>

<!-- dtl:block:TicketService -->
                    <label for="ServiceID">$Text{"Service"}:</label>
                    <div class="Field">
                        $Data{"ServiceStrg"}
                        <div id="ServiceIDServerError" class="TooltipErrorMessage"><p>$Text{"Service invalid."}</p></div>
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    $('#ServiceID').bind('change', function (Event) {
        Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'ServiceID', ['TypeID', 'Dest', 'NewUserID', 'NewResponsibleID', 'NextStateID', 'PriorityID', 'SLAID', 'SignKeyID', 'CryptKeyID', $Data{"DynamicFieldNamesStrg"}, 'To', 'Cc', 'Bcc']);
    });
//]]></script>
<!--dtl:js_on_document_complete-->
                    </div>
                    <div class="Clear"></div>
<!-- dtl:block:TicketService -->

<!-- dtl:block:TicketSLA -->
                    <label for="SLAID">$Text{"Service Level Agreement"}:</label>
                    <div class="Field">
                        $Data{"SLAStrg"}
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    $('#SLAID').bind('change', function (Event) {
        Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'SLAID', ['TypeID', 'Dest', 'NewUserID', 'NewResponsibleID', 'ServiceID', 'NextStateID', 'PriorityID', 'SignKeyID', 'CryptKeyID', $Data{"DynamicFieldNamesStrg"}, 'To', 'Cc', 'Bcc']);
    });
//]]></script>
<!--dtl:js_on_document_complete-->
                    </div>
                    <div class="Clear"></div>
<!-- dtl:block:TicketSLA -->

<!-- dtl:block:OwnerSelection -->
                    <label for="NewUserID">$Text{"Owner"}:</label>
                    <div class="Field">
                        $Data{"OptionStrg"}
                        <a href="#" id="OwnerSelectionGetAll" class="GetAllAJAX" title="$Text{"Get all"}">$Text{"Get all"}</a>
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    $('#OwnerSelectionGetAll').bind('click', function (Event) {
        $('#OwnerAll').val('1'); // Needed? Why?
        Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'OwnerAll', ['NewUserID'], function() {
            $('#NewUserID').focus();
        });
        return false;
    });

    $('#NewUserID').bind('change', function (Event) {
        Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'NewUserID', [ 'TypeID', 'Dest', 'NewResponsibleID', 'NextStateID', 'PriorityID', 'ServiceID', 'SLAID', 'SignKeyID', 'CryptKeyID', $Data{"DynamicFieldNamesStrg"}, 'To', 'Cc', 'Bcc']);
    });
//]]></script>
<!--dtl:js_on_document_complete-->
                    </div>
                    <div class="Clear"></div>
<!-- dtl:block:OwnerSelection -->

<!-- dtl:block:ResponsibleSelection -->
                    <label for="NewResponsibleID">$Text{"Responsible"}:</label>
                    <div class="Field">
                        $Data{"ResponsibleOptionStrg"}
                        <a href="#" id="ResponsibleSelectionGetAll" class="GetAllAJAX" title="$Text{"Get all"}">$Text{"Get all"}</a>
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    $('#ResponsibleSelectionGetAll').bind('click', function (Event) {
        $('#ResponsibleAll').val('1'); // Needed? Why?
        Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'ResponsibleAll', ['NewResponsibleID'], function() {
            $('#NewResponsibleID').focus();
        });
        return false;
    });

    $('#NewResponsibleID').bind('change', function (Event) {
        Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'NewResponsibleID', [ 'TypeID', 'Dest', 'NewUserID', 'NextStateID', 'PriorityID', 'ServiceID', 'SLAID', 'SignKeyID', 'CryptKeyID', $Data{"DynamicFieldNamesStrg"}, 'To', 'Cc', 'Bcc']);
    });
//]]></script>
<!--dtl:js_on_document_complete-->
                    </div>
                    <div class="Clear"></div>
<!-- dtl:block:ResponsibleSelection -->

                    <label class="Mandatory" for="Subject"><span class="Marker">*</span> $Text{"Subject"}:</label>
                    <div class="Field">
                        <input class="W75pc Validate_Required $QData{"SubjectInvalid"}" type="text" name="Subject" id="Subject" value="$QData{"Subject"}"/>
                        <div id="SubjectError" class="TooltipErrorMessage">
                            <p>$Text{"This field is required."}</p>
                        </div>
                        <div id="SubjectServerError" class="TooltipErrorMessage">
                            <p>$Text{"This field is required."}</p>
                        </div>
                    </div>
                    <div class="Clear"></div>

<!-- dtl:block:TicketOptions -->
                    <label>$Text{"Options"}:</label>
                    <div class="Field">

<!-- OutputFilterHook_TicketOptionsBegin -->

<!-- dtl:block:SpellCheck -->
                        <a href="#" id="OptionSpellCheck">[ $Text{"Spell check"} ]</a>
<!-- dtl:block:SpellCheck -->

<!-- dtl:block:OptionCustomer -->
                        <a href="#" id="OptionCustomer">[ $Text{"Customer"} ]</a>
<!-- dtl:block:OptionCustomer -->

<!-- OutputFilterHook_TicketOptionsEnd -->

                    </div>
                    <div class="Clear"></div>
<!-- dtl:block:TicketOptions -->

<!-- OutputFilterHook_NoTicketOptionsFallback -->

                    <label class="Mandatory" for="RichText"><span class="Marker">*</span> $Text{"Text"}:</label>
                    <div class="RichTextField">

<!-- dtl:block:RichText -->
$Include{"RichTextEditor"}
<!-- dtl:block:RichText -->
                        <textarea id="RichText" class="RichText Validate_Required $QData{"RichTextInvalid"}" name="Body" title="Message body" rows="15" cols="$Config{"Ticket::Frontend::TextAreaNote"}">$QData{"Body"}</textarea>
                        <div id="RichTextError" class="TooltipErrorMessage">
                            <p>$Text{"This field is required."}</p>
                        </div>
                        <div id="RichTextServerError" class="TooltipErrorMessage">
                            <p>$Text{"This field is required."}</p>
                        </div>
                    </div>
                    <div class="Clear"></div>

                    <label>$Text{"Attachment"}:</label>
                    <div class="Field">
                        <ul>
<!-- dtl:block:Attachment -->
                            <li>
                                $QData{"Filename"} ($QData{"Filesize"})
                                <button type="button" id="AttachmentDeleteButton$QData{"FileID"}" name="AttachmentDeleteButton$QData{"FileID"}" value="$Text{"Delete"}" class="SpacingLeft">$Text{"Delete"}</button>
                                <input type="hidden" id="AttachmentDelete$QData{"FileID"}" name="AttachmentDelete$QData{"FileID"}" />
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    $('#AttachmentDeleteButton$QData{"FileID"}').bind('click', function () {
        var $Form = $('#AttachmentDeleteButton$QData{"FileID"}').closest('form');
        $('#AttachmentDelete$QData{"FileID"}').val(1);
        Core.Form.Validate.DisableValidation($Form);
        $Form.trigger('submit');
    });
//]]></script>
<!--dtl:js_on_document_complete-->
                            </li>
<!-- dtl:block:Attachment -->
                            <li>
                                <input id="FileUpload" name="FileUpload" type="file" size="40" />
                                <input type="hidden" id="AttachmentUpload" name="AttachmentUpload" value="0" />
                            </li>
                        </ul>
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    $('#FileUpload').bind('change', function () {
        var $Form = $('#FileUpload').closest('form');
        Core.Form.Validate.DisableValidation($Form);
        $Form.find('#AttachmentUpload').val('1').end().submit();
    });
//]]></script>
<!--dtl:js_on_document_complete-->
                    </div>
                    <div class="Clear"></div>

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

                    <label for="NextStateID">$Text{"Next ticket state"}:</label>
                    <div class="Field">
                        $Data{"NextStatesStrg"}
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    $('#NextStateID').bind('change', function (Event) {
        Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'NextStateID', [ 'TypeID', 'Dest', 'NewUserID','NewResponsibleID', 'PriorityID', 'ServiceID', 'SLAID', 'SignKeyID', 'CryptKeyID', $Data{"DynamicFieldNamesStrg"}, 'To', 'Cc', 'Bcc']);
    });
//]]></script>
<!--dtl:js_on_document_complete-->
                    </div>
                    <div class="Clear"></div>

                    <label>$Text{"Pending Date"} ($Text{"for pending* states"}):</label>
                    <div class="Field">
                        $Data{"PendingDateString"}
                        <div id="DayError" class="TooltipErrorMessage"><p>$Text{"Date invalid!"}</p></div>
                        <div id="HourError" class="TooltipErrorMessage"><p>$Text{"Date invalid!"}</p></div>
                    </div>
                    <div class="Clear"></div>

                    <label for="PriorityID">$Text{"Priority"}:</label>
                    <div class="Field">
                        $Data{"PriorityStrg"}
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    $('#PriorityID').bind('change', function (Event) {
        Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'PriorityID', [ 'TypeID', 'Dest', 'NewUserID','NewResponsibleID', 'NextStateID', 'ServiceID', 'SLAID', 'SignKeyID', 'CryptKeyID', $Data{"DynamicFieldNamesStrg"}, 'To', 'Cc', 'Bcc']);
    });
//]]></script>
<!--dtl:js_on_document_complete-->
                    </div>
                    <div class="Clear"></div>

<!-- dtl:block:DynamicField -->
                    <div class="Row Row_DynamicField_$QData{"Name"}">
                        $Data{"Label"}
                        <div class="Field">
                            $Data{"Field"}
                        </div>
                        <div class="Clear"></div>
                    </div>
<!-- dtl:block:DynamicField -->

# example of how to use fixed dynamic field blocks for customizations
# Note: Field1 and Field2 are the names of the fields and had to be replaced with the actual
# field names
#<!-- dtl:block:DynamicField_Field1 -->
#                    <div class="Row Row_DynamicField_$QData{"Name"}">
#                        $Data{"Label"}
#                        <div class="Field">
#                            $Data{"Field"}
#                        </div>
#                        <div class="Clear"></div>
#                    </div>
#<!-- dtl:block:DynamicField_Field1 -->
#<!-- dtl:block:DynamicField_Field2 -->
#                    <div class="Row Row_DynamicField_$QData{"Name"}">
#                        $Data{"Label"}
#                        <div class="Field">
#                            $Data{"Field"}
#                        </div>
#                        <div class="Clear"></div>
#                    </div>
#<!-- dtl:block:DynamicField_Field2 -->

<!-- dtl:block:TimeUnitsLabel -->
                    <label for="TimeUnits">$Text{"Time units"}$Text{"$Config{"Ticket::Frontend::TimeUnits"}"}:</label>
<!-- dtl:block:TimeUnitsLabel -->
<!-- dtl:block:TimeUnitsLabelMandatory -->
                    <label class="Mandatory" for="TimeUnits"><span class="Marker">*</span> $Text{"Time units"}$Text{"$Config{"Ticket::Frontend::TimeUnits"}"}:</label>
<!-- dtl:block:TimeUnitsLabelMandatory -->
<!-- dtl:block:TimeUnits -->
                    <div class="Field">
                        <input type="text" class="W25pc Validate_TimeUnits $QData{"TimeUnitsRequired"} $QData{"TimeUnitsInvalid"}" name="TimeUnits" id="TimeUnits" value="$QData{"TimeUnits"}" />
                        <div id="TimeUnitsError" class="TooltipErrorMessage"><p>$Text{"Invalid time!"}</p></div>
                        <div id="TimeUnitsServerError" class="TooltipErrorMessage"><p>$Text{"This field is required."}</p></div>
                    </div>
                    <div class="Clear"></div>
<!-- dtl:block:TimeUnits -->
                    <div class="Field SpacingTop">
                        <button class="Primary" id="submitRichText" accesskey="g" title="$Text{"Create"} (g)" type="submit" value="$Text{"Create"}">$Text{"Create"}</button>
                    </div>
                </fieldset>
            </form>
        </div>
    </div>
    <div id="CustomerTickets"></div>
</div>

<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    Core.Agent.TicketAction.Init();
//]]></script>
<!--dtl:js_on_document_complete-->

# example template form for customizations
#<form action="$Env{"CGIHandle"}" method="post" enctype="multipart/form-data" id="Template1">
#    <input type="hidden" name="Action" value="$Env{"Action"}"/>
#    <input type="hidden" name="Subaction" value="StoreNew"/>
#    <input type="hidden" name="FormID" value="$QData{"FormID"}"/>
#    <input type="hidden" name="ExpandCustomerName" value="1"/>
#    <input type="hidden" name="Subject" value="Example Subject"/>
#    <input type="hidden" name="Body" value="Name:
#Product:
#Comment:"/>
#</form>
