Skip to content
Snippets Groups Projects
ticket-view.inc.php 53.1 KiB
Newer Older
  • Learn to ignore specific revisions
  •         <?php csrf_token(); ?>
            <input type="hidden" name="id" value="<?php echo $ticket->getId(); ?>">
            <input type="hidden" name="a" value="process">
            <input type="hidden" name="do" id="action" value="">
            <hr style="margin-top:1em"/>
            <p class="full-width">
    
                <span class="buttons pull-left">
    
                    <input type="button" value="<?php echo __('Cancel');?>" class="close">
    
                <span class="buttons pull-right">
    
                    <input type="submit" value="<?php echo __('OK');?>">
    
    <script type="text/javascript">
    $(function() {
        $(document).on('click', 'a.change-user', function(e) {
            e.preventDefault();
            var tid = <?php echo $ticket->getOwnerId(); ?>;
            var cid = <?php echo $ticket->getOwnerId(); ?>;
            var url = 'ajax.php/'+$(this).attr('href').substr(1);
            $.userLookup(url, function(user) {
                if(cid!=user.id
                        && $('.dialog#confirm-action #changeuser-confirm').length) {
    
                    $('#newuser').html(user.name +' &lt;'+user.email+'&gt;');
    
                    $('.dialog#confirm-action #action').val('changeuser');
                    $('#confirm-form').append('<input type=hidden name=user_id value='+user.id+' />');
                    $('#overlay').show();
                    $('.dialog#confirm-action .confirm-action').hide();
                    $('.dialog#confirm-action p#changeuser-confirm')
                    .show()
                    .parent('div').show().trigger('click');
                }
            });
        });
    
    
        // Post Reply or Note action buttons.
        $('a.post-response').click(function (e) {
            var $r = $('ul.tabs > li > a'+$(this).attr('href')+'-tab');
            if ($r.length) {
                // Make sure ticket thread tab is visiable.
                var $t = $('ul#ticket_tabs > li > a#ticket-thread-tab');
                if ($t.length && !$t.hasClass('active'))
                    $t.trigger('click');
                // Make the target response tab active.
                if (!$r.hasClass('active'))
                    $r.trigger('click');
    
                // Scroll to the response section.
                var $stop = $(document).height();
                var $s = $('div#response_options');
                if ($s.length)
                    $stop = $s.offset().top-125
    
                $('html, body').animate({scrollTop: $stop}, 'fast');
            }
    
            return false;
        });
    
    
    
    $(function() {
        $("#cc_users").select2({width: '350px'});
        $("#bcc_users").select2({width: '350px'});
    });
    
    $(function() {
       $('#cc_users').on("select2:select", function(e) {
         var el = $(this);
         var tid = <?php echo $ticket->getThreadId(); ?>;
    
        if(el.val().includes("NEW")) {
          $("li[title='— Add New —']").remove();
          var url = 'ajax.php/thread/' + tid + '/add-collaborator' ;
           $.userLookup(url, function(user) {
             e.preventDefault();
              if($('.dialog#confirm-action').length) {
                  $('.dialog#confirm-action #action').val('addcc');
                  $('#confirm-form').append('<input type=hidden name=user_id value='+user.id+' />');
                  $('#overlay').show();
              }
           });
              var arr = el.val();
              var removeStr = "NEW";
    
              arr.splice($.inArray(removeStr, arr),1);
              $(this).val(arr);
         }
      });
    
      $('#bcc_users').on("select2:select", function(e) {
          var el = $(this);
          var tid = <?php echo $ticket->getThreadId(); ?>;
    
          if(el.val().includes("NEW")) {
            $("li[title='— Add New —']").remove();
            var url = 'ajax.php/thread/' + tid + '/add-collaborator' ;
             $.userLookup(url, function(user) {
                e.preventDefault();
                if($('.dialog#confirm-action').length) {
                    $('.dialog#confirm-action #action').val('addbcc');
                    $('#confirm-form').append('<input type=hidden name=user_id value='+user.id+' />');
                    $('#overlay').show();
                }
             });
             var arr = el.val();
             var removeStr = "NEW";
    
             arr.splice($.inArray(removeStr, arr),1);
             $(this).val(arr);
          }
      });
    
      $('#cc_users').on("select2:unselecting", function(e) {
          var confirmation = confirm(__("Are you sure you want to remove the collaborator from receiving this reply?"));
          if (confirmation == false) {
            $('#cc_users').on("select2:opening", function(e) {
              return false;
            });
            return false;
          }
    
     });
    
     $('#bcc_users').on("select2:unselecting", function(e) {
         var confirmation = confirm(__("Are you sure you want to remove the collaborator from receiving this reply?"));
         if (confirmation == false) {
             $('#bcc_users').on("select2:opening", function(e) {
               return false;
             });
             return false;
           }
     });
    });
    
    </script>