<?php
/**
 * Copyright 2012 Zendesk.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
?>
<?php if( Mage::helper('zendesk')->isConnected() ): ?>
    <?php if ($this->getIsZendeskDashboard() || Mage::getStoreConfig('zendesk/backend_features/show_on_dashboard')): ?>
        <?php if ($this->getIsZendeskDashboard()): ?>
            <div class="content-header">
                <table cellspacing="0">
                    <tr>
                        <td><h3 class="head-dashboard"><?php echo $this->__('Dashboard') ?></h3></td>
                    </tr>
                </table>
            </div>
        <?php else: ?>
            <script>
                document.observe('dom:loaded', function(){
                    if($('dashboard_diagram_totals')) {
                        $('dashboard_diagram_totals').insert({ after:$('zendesk_dashboard_container') });
                    }
                });
            </script>
        <?php endif; ?>
        <div class="zendesk_dashboard_container" id="zendesk_dashboard_container">
            <?php echo $this->getChildHtml('zendesk_dashboard_grids') ?>
            <div id="tickets_grid_tab_content"></div>
            <?php if (!$this->getIsZendeskDashboard()): ?>
                <div class="a-right" style="margin: 6px 0;">
                    <button style="" onclick="setLocation('<?php echo $this->getUrl('adminhtml/zendesk/create'); ?>');" class="scalable" type="button" id="zendesk-create-ticket">
                        <span><?php echo $this->__('New Support Ticket'); ?></span>
                    </button>
                    <button style="" onclick="setLocation('<?php echo Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/zendesk/launch'); ?>');" class="scalable" type="button" id="zendesk-view-all">
                        <span><?php echo $this->__('View All Tickets'); ?></span>
                    </button>
                </div>
            <?php endif; ?>
        </div>
        <?php echo $this->getChildHtml('zendesk_dashboard_empty'); ?>
    <?php endif; ?>
<?php endif; ?>
