Skip to content
Snippets Groups Projects
ticket-tasks.inc.php 6.19 KiB
Newer Older
  • Learn to ignore specific revisions
  • global $thisstaff;
    
    $role = $thisstaff->getRole($ticket->getDeptId());
    
    $tasks = Task::objects()
    
        ->select_related('dept', 'staff', 'team')
    
        ->order_by('-created');
    
    $tasks->filter(array(
                'object_id' => $ticket->getId(),
                'object_type' => 'T'));
    
    $count = $tasks->count();
    $pageNav = new Pagenate($count,1, 100000); //TODO: support ajax based pages
    $showing = $pageNav->showing().' '._N('task', 'tasks', $count);
    
    
    ?>
    <div id="tasks_content" style="display:block;">
    
    <div class="pull-left">
    
        if ($count) {
            echo '<strong>'.$showing.'</strong>';
    
        } else {
    
            echo sprintf(__('%s does not have any tasks'), $ticket? 'This ticket' :
    
                    'System');
        }
       ?>
    </div>
    
    <div class="pull-right">
    
        if ($role && $role->hasPerm(Task::PERM_CREATE)) { ?>
    
    Peter Rotich's avatar
    Peter Rotich committed
            class="green button action-button ticket-task-action"
    
            data-url="tickets.php?id=<?php echo $ticket->getId(); ?>#tasks"
    
    Peter Rotich's avatar
    Peter Rotich committed
            data-dialog-config='{"size":"large"}'
    
            href="#tickets/<?php
    
                echo $ticket->getId(); ?>/add-task">
                <i class="icon-plus-sign"></i> <?php
    
                print __('Add New Task'); ?></a>
        <?php
    
        if ($count)
            Task::getAgentActions($thisstaff, array('morelabel' => __('Options')));
    
    Peter Rotich's avatar
    Peter Rotich committed
    <div class="clear"></div>
    
    if ($count) { ?>
    
    <form action="#tickets/<?php echo $ticket->getId(); ?>/tasks" method="POST"
        name='tasks' id="tasks" style="padding-top:7px;">
    
    <?php csrf_token(); ?>
     <input type="hidden" name="a" value="mass_process" >
     <input type="hidden" name="do" id="action" value="" >
     <table class="list" border="0" cellspacing="1" cellpadding="2" width="940">
        <thead>
            <tr>
                <?php
    
                if (1) {?>
    
                <th width="8px">&nbsp;</th>
                <?php
                } ?>
                <th width="70"><?php echo __('Number'); ?></th>
                <th width="100"><?php echo __('Date'); ?></th>
                <th width="100"><?php echo __('Status'); ?></th>
                <th width="300"><?php echo __('Title'); ?></th>
                <th width="200"><?php echo __('Department'); ?></th>
                <th width="200"><?php echo __('Assignee'); ?></th>
            </tr>
        </thead>
        <tbody class="tasks">
        <?php
    
        foreach($tasks as $task) {
            $id = $task->getId();
    
            $assigned='';
    
            if ($task->staff)
                $assigned=sprintf('<span class="Icon staffAssigned">%s</span>',
                        Format::truncate($task->staff->getName(),40));
    
    
            $status = $task->isOpen() ? '<strong>open</strong>': 'closed';
    
            $title = Format::htmlchars(Format::truncate($task->getTitle(),40));
    
            $threadcount = $task->getThread() ?
                $task->getThread()->getNumEntries() : 0;
    
    
            $viewhref = sprintf('#tickets/%d/tasks/%d/view',
                    $ticket->getId(), $id);
    
    
            <tr id="<?php echo $id; ?>">
    
                <td align="center" class="nohover">
                    <input class="ckb" type="checkbox" name="tids[]"
    
                    value="<?php echo $id; ?>" <?php echo $sel?'checked="checked"':''; ?>>
    
                </td>
                <td align="center" nowrap>
                  <a class="Icon no-pjax preview"
                    title="<?php echo __('Preview Task'); ?>"
    
                    href="<?php echo $viewhref; ?>"
    
                    data-preview="#tasks/<?php echo $id; ?>/preview"
    
                    ><?php echo $task->getNumber(); ?></a></td>
                <td align="center" nowrap><?php echo
    
                Format::datetime($task->created); ?></td>
    
                <td><?php echo $status; ?></td>
                <td><a <?php if ($flag) { ?> class="no-pjax"
                        title="<?php echo ucfirst($flag); ?> Task" <?php } ?>
    
                        href="<?php echo $viewhref; ?>"><?php
    
                    echo $title; ?></a>
                     <?php
                        if ($threadcount>1)
                            echo "<small>($threadcount)</small>&nbsp;".'<i
                                class="icon-fixed-width icon-comments-alt"></i>&nbsp;';
                        if ($row['collaborators'])
                            echo '<i class="icon-fixed-width icon-group faded"></i>&nbsp;';
                        if ($row['attachments'])
                            echo '<i class="icon-fixed-width icon-paperclip"></i>&nbsp;';
                    ?>
                </td>
    
                <td><?php echo Format::truncate($task->dept->getName(), 40); ?></td>
    
                <td>&nbsp;<?php echo $assigned; ?></td>
            </tr>
       <?php
        }
        ?>
        </tbody>
    </table>
    </form>
    <?php
     } ?>
    </div>
    </div>
    <div id="task_content" style="display:none;">
    </div>
    <script type="text/javascript">
    $(function() {
    
    Peter Rotich's avatar
    Peter Rotich committed
        $(document).off('click.taskv');
        $(document).on('click.taskv', 'tbody.tasks a, a#reload-task', function(e) {
    
            e.preventDefault();
    
    Peter Rotich's avatar
    Peter Rotich committed
            e.stopImmediatePropagation();
    
            var url = 'ajax.php/'+$(this).attr('href').substr(1);
            var $container = $('div#task_content');
    
            var $stop = $('ul#ticket_tabs').offset().top;
            $.pjax({url: url, container: $container, push: false, scrollTo: $stop})
            .done(
                function() {
                $container.show();
    
                $('.tip_box').remove();
                $('div#tasks_content').hide();
    
    Peter Rotich's avatar
    Peter Rotich committed
    
    
            return false;
         });
    
    Peter Rotich's avatar
    Peter Rotich committed
        // Ticket Tasks
        $(document).off('.ticket-task-action');
        $(document).on('click.ticket-task-action', 'a.ticket-task-action', function(e) {
    
            e.preventDefault();
            var url = 'ajax.php/'
            +$(this).attr('href').substr(1)
            +'?_uid='+new Date().getTime();
            var $redirect = $(this).data('href');
    
    Peter Rotich's avatar
    Peter Rotich committed
            var $options = $(this).data('dialogConfig');
    
            $.dialog(url, [201], function (xhr) {
                var tid = parseInt(xhr.responseText);
                if (tid) {
    
    Peter Rotich's avatar
    Peter Rotich committed
                    var url = 'ajax.php/tickets/'+<?php echo $ticket->getId();
                    ?>+'/tasks/'+tid+'/view';
    
                    var $container = $('div#task_content');
                    $container.load(url, function () {
                        $('.tip_box').remove();
                        $('div#tasks_content').hide();
                    }).show();
                } else {
                    window.location.href = $redirect ? $redirect : window.location.href;
                }
            }, $options);
            return false;
        });
    
    });
    </script>