<!--
****************************************************************************  
*  Description: Layout for tickets content                                 *
*  Created: 05/22/2006                                                     *
****************************************************************************
-->


<script type="text/javascript" src="../javascript/modules/support.js?version={VERSION}"></script>
<script type="text/javascript">
    var NotificationBtn = '';
    
    Ext.onReady(function(){
        DeleteBtn = new Ext.Button({
            text:     lang('Delete'),
            renderTo: 'ExtDeleteTicketBtn',
            type:     'submit',
            width:    100,
            handler:  function(){
                          return deleteTicket();
                      }
        });

        NextBtn = new Ext.Button({
            text: lang('Next')+" &#155;",
            renderTo: 'ExtNextTicketBtn',
            type:   'button',
            width: 50,
            handler: function(){
                increaseStartValue(1);
                return false;
            }
        });

        PreviousBtn = new Ext.Button({
            text: "&#139; "+lang('Previous'),
            renderTo: 'ExtPreviousTicketBtn',
            type:   'button',
            width: 50,
            handler: function(){
                increaseStartValue(-1);
                return false;
            }
        });

        NotificationBtn = new Ext.Button({
            id:       'ticketAdditionalNotificationButton',
            text:     '{TICKET_ADDITIONAL_NOTIFICATION_TITLE}',
            renderTo: 'ExtTicketAdditionalNotificationButton',
            type:     'button',
            width:    100,
            handler:  function(){
                          ticketAdditionalNotification();
                      }
        });
    });

    onLoadFunctions.push(
        function()
        {
            changeTicketType({TICKETID}, '{EXTRA_ARGS}');
        }
    );

    function deleteTicket()
    {
        var val = confirm(lang("Click OK if you are sure you want to delete this ticket"));
        if(val){
            window.location = "index.php?fuse=support&action=DeleteTicket&ticketid={TICKETID}";
        }
    }

    function ticketAdditionalNotification()
    {
        var ticketId = $('ticketid').value;
        var ticketAdditionalNotificationId = $('ticketAdditionalNotificationId').value;
        
        if(ticketId == 0){
            return;
        }
        if(ticketAdditionalNotificationId == 0){
            new Ajax.Request(
                'index.php?fuse=support&action=AddTicketAdditionalNotification_ASync&ticketid=' + ticketId,
                {
                    onSuccess: AddTicketAdditionalNotification
                }
            );
        }else{
            new Ajax.Request(
                'index.php?fuse=support&action=DeleteTicketAdditionalNotification_ASync&additionalNotificationID=' + ticketAdditionalNotificationId,
                {
                    onSuccess: DeleteTicketAdditionalNotification
                }
            );
        }
    }

    function AddTicketAdditionalNotification(responseObj)
    {
        var responseArr = responseObj.responseText.split('|');
        
        if(typeof responseArr[1] == 'undefined' || responseArr[0] != 'OK'){
            alert(responseObj.responseText);
        }else{
            $('ticketAdditionalNotificationId').value = responseArr[1];
            NotificationBtn.setText(lang("Unsubscribe"));
        }
    }

    function DeleteTicketAdditionalNotification(responseObj)
    {
        if(responseObj.responseText == 'OK'){
            $('ticketAdditionalNotificationId').value = 0;
            NotificationBtn.setText(lang("Subscribe"));
        }else{
            alert(responseObj.responseText);
        }
    }
    
    function increaseStartValue(increaseValue)
    {
        new Ajax.Request('index.php?fuse=support&action=IncreaseStartValue',
                         {parameters     : 'increaseValue=' + encodeURIComponent(increaseValue),
                          onComplete     : increaseStartValue_Callback});
    }
    
    function increaseStartValue_Callback(responseObj)
    {
        var responseArr = responseObj.responseText.split('|');
        if(responseArr[0] == 1){
            if(responseArr[1] == -1){
                this.location = "index.php?fuse=support&view=Admin_ViewTicketMessage&ticketID={PREVIOUS_TICKET_ID}";
            }else if(responseArr[1] == 1){
                this.location = "index.php?fuse=support&view=Admin_ViewTicketMessage&ticketID={NEXT_TICKET_ID}";
            }
        }
    }
    
    {TICKET_TYPE_ARRAY}
</script>

<!--<div class="inside">-->
<!--<div class="inside">-->
    <!--<div id="ticketDetailsDiv" style"width:660px">-->
    <div>
           <!--<table bgcolor=white cellpadding=0 cellspacing=0 border=0 width=823px>-->
           <table cellpadding='0' cellspacing='0' border='0' width="100%">
            <tr>
                <td colspan="6">
                    <div  style="width:auto;">
                        <input type="hidden" id="originalStatus" value="{TICKET_STATUS}" />
                        <input type="hidden" id="originalPriority" value="{TICKET_PRIORITY}" />
                        <input type="hidden" id="originalType" value="{TICKET_TYPE}" />

                        <input type="hidden" id="ticket_owner_id" value="{TICKET_OWNER_ID}" />
                        <input type="hidden" id="originalAssignedToName" value="{TICKET_ASSIGNEE}" />
                        <input type="hidden" id="assignedToId" value="{TICKET_ASSIGNED_TO_ID}" />
                        <input type="hidden" id="userId" value="{USER_ID}" />

                                <div class="info_user">                                    
                                    <div class="heading_line_usr" style="margin-bottom:15px;padding-top:8px;">
                                        <span style="position:relative;top:3px;"><a onclick="HideShowAndUpdateCustomField($('ticketdetails'),'toggle0','Ticket_ShowHeader');return false;"><img alt="toggleimage" src='../images/collapse.gif' border='0' name='toggle0' /></a>&nbsp;</span>
                                        <span class="snapshot-header-text" style="font-size:24px;"><a onclick="HideShowAndUpdateCustomField($('ticketdetails'),'toggle0','Ticket_ShowHeader');return false;">[l]TKT[/l] #{TICKET_HEADER_NUMBER}</a><!--&nbsp;&nbsp;[l]By[/l] {TICKET_OWNERLINK}&nbsp;--></span>&nbsp;&nbsp;&nbsp;
                                        <span id="tdSubject" style="position:relative;top:-1px;font-size:24px;"><span class="{PRIORITY_COLOR}">&nbsp;{TICKET_HEADER_SUBJECT}</span></span>
                                        <input type="hidden" id="originalSubject" value="{TICKET_SUBJECT}" />
                                        
                                        
                                        
                                    </div><!-- CLose div.heading_line_usr -->

                                    <div id="ticketdetails" style="padding-bottom:10px;display:{ticketheader_style}">
                                        <div class="box_long_bottom">

                                            <span class="ticketCreatedDiv">
                                                <div class="ticketCreatedDate">
                                                        <span style="font-weight:bold;color:black;">[l]Created[/l] </span>
                                                    <strong>{TICKET_DATESUBMITTED}</strong>
                                                    <!--<strong>12:03:14 am</strong>-->
                                                </div><!-- Close div.ticketCreatedDate -->
                                                <div class="ticketElapsedDate">
                                                    <span style="font-weight:bold;color:black;">[l]Status[/l]</span>
                                                    <strong><span id="ticket_status_link" class="value">{TICKET_STATUS_LINK}</span></strong>
                                                    <!--<strong>15 hrs 43 mins</strong>-->
                                                </div><!-- Close div.ticketElapsedDate -->
                                            </span><!-- Close div.ticketCreatedDiv -->
                                            <span>
                                            <ul id="ticketdetailsright" class="ticketdetailright">
                                                <li><span class="label">[l]Opened by[/l]:</span><span class="value">{TICKET_OWNERLINK}</span></li>
                                                <li><span class="label">[l]Assigned[/l]:</span><span id="assignedtoname" class="value">{TICKET_ASSIGNEE_LINK}</span></li>
                                                <li><span class="label">[l]Ticket Type[/l]:</span><span id="tdType" class="value">{TICKET_TYPE_LINK}</span></li>
                                                <li><span class="label">[l]Package[/l]:</span><span class="value"><span id="tdDomain"> {TICKET_DOMAIN_LINK}&nbsp;&nbsp;</span><span id="ticket_packagename">{TICKET_PACKAGENAME}</span></span></li>
                                                <li><span class="label">[l]Priority[/l]:</span><span id="tdPriority" class="value" {TICKET_PRIORITYCLASS} >{TICKET_PRIORITY_LINK}</span>
                                                <input type="hidden" id="ticketid" name="ticketid" value="{TICKET_ID}" />
                                                <input type="hidden" id="originalDomain" value="{TICKET_DOMAIN}" />
                                            </ul>
                                            </span>
                                        </div><!-- Close div.box_long_bottom -->

                                        <!-- BEGIN DYNAMIC BLOCK: ticketRate -->
                                            <div>
                                                [l]Customer Rating[/l]: {TICKET_RATE}
                                            </div>
                                        <!-- END DYNAMIC BLOCK: ticketRate -->

                                        <!-- BEGIN DYNAMIC BLOCK: ticket_attachment_toggle -->
                                        <div id="viewattachedfileblocktoggle" style="float:left;margin-bottom:30px;padding-left:2px;">
                                            <a class="liveupdate" href="javascript:hideshow($('viewattachedfileblocktoggle'));hideshow($('attachedfileblock'));"><b>[l]View attached files[/l]</b></a>
                                        </div>
                                        <div id="attachedfileblock" style="display:none;">
                                            <a class="liveupdate" href="javascript:hideshow($('viewattachedfileblocktoggle'));hideshow($('attachedfileblock'));"><b>[l]Collapse attached files[/l]</b></a>
                                            <!-- BEGIN DYNAMIC BLOCK: ticket_attachment -->
                                            <div style="font-size:10px !important;">
                                                <span>
                                                    [l]Attachment[/l]:
                                                </span>
                                                <span>
                                                    {ATTACHMENT_URL}
                                                    <!-- BEGIN DYNAMIC BLOCK: ticket_attachment_remove -->
                                                    &nbsp;&nbsp;[<span style="color:red">&nbsp{ATTACHMENT_REMOVEURL}&nbsp;</span>]&nbsp;
                                                    <!-- END DYNAMIC BLOCK: ticket_attachment_remove -->
                                                </span>
                                            </div>
                                            <!-- END DYNAMIC BLOCK: ticket_attachment -->
                                        </div>
                                        <!-- END DYNAMIC BLOCK: ticket_attachment_toggle -->

                                    </div><!-- Close div.ticketdetials - part that hides on collapse-->
                                </div><!-- Close div.class.info_user -->
                                  

                    </div>

                    <div style="position:relative;clear:both;">
                        <ul id="ajaxTabs" class="tabs">
                            <li {viewticketmessageactive} name='tickettab' id='tickettab_messages_tab'>
                                <a href="index.php?fuse=support&view=Admin_ViewTicketMessage&ticketID={TICKETID}&email={GUEST_EMAIL}&accesscode={ACCESS_CODE}&customerId={TICKET_OWNER_ID}">Messages</a>
                            </li>

                            <!-- BEGIN DYNAMIC BLOCK: ticketeventtab -->
                            <li {viewticketeventtabactive} name='tickettab' id='tickettab_eventlog_tab'>
                                <a href="index.php?fuse=support&view=Admin_TicketEvents&ticketID={TICKETID}&email={GUEST_EMAIL}&accesscode={ACCESS_CODE}&customerId={TICKET_OWNER_ID}">Event Log</a>
                            </li>
                            <!-- END DYNAMIC BLOCK: ticketeventtab -->

                            <!-- template below used for dynamic tabs that get added after page load -->
                            <!-- BEGIN DYNAMIC BLOCK: tickettab -->
                            <li class="{TICKETTAB_CLASS}" name='tickettab' id='{TICKETTAB_ID}_tab'>
                                <a href="{TICKETTAB_URL}">{TICKETTAB_NAME}</a>
                            </li>
                            <!-- END DYNAMIC BLOCK: tickettab -->
                        </ul>
                        <div style="position:absolute; right:0; bottom:5px; border:1x solid blue">
                            <table>
                                <tr>
                                    <td>
                                        <span id='ExtPreviousTicketBtn' style="display: {PREVIOUS_TICKET_DISPLAY}"></span>
                                    </td>
                                    <td nowrap align=center valign=center>
                                        &nbsp;
                                    </td>
                                    <td>
                                        <!--<span style="display: {SEPARATOR_DISPLAY}">&nbsp;|&nbsp;</span>-->
                                        <span id='ExtNextTicketBtn' style="display: {NEXT_TICKET_DISPLAY}"></span>
                                    </td>
                                    <td nowrap align=center valign=center>
                                        &nbsp;
                                    </td>
                                    <td nowrap align=center valign=center>
                                        <span id="notificationButton" style="display:{STYLE_TICKET_NOTIFICATIONS}">
                                            <span id='ExtTicketAdditionalNotificationButton'></span>
                                            <input type="hidden" id="ticketAdditionalNotificationId" value="{TICKET_ADDITIONAL_NOTIFICATION_ID}" />
                                        </span>
                                    </td>
                                    <!-- BEGIN DYNAMIC BLOCK: deleteTicketBtn -->
                                    <td nowrap align=center valign=center>
                                        &nbsp;
                                    </td>
                                    <td nowrap align=center valign=center>
                                            <span id='ExtDeleteTicketBtn'></span>
                                    </td>
                                    <!-- END DYNAMIC BLOCK: deleteTicketBtn -->
                                </tr>
                            </table>
                        </div>
                    </div>
                    <div id="activetickettab">
                    </div>
                </td>
            </tr>
        </table>
    </div>