summaryrefslogtreecommitdiff
path: root/rt/share/html/Search/Schedule.html
blob: 34ba142bdf0e24345c56cb210dfe97d7027fda05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<& /Elements/Header, Title => 'Schedule' &>

%#init_overlib.html
%foreach my $file (@files) {
<SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/<%$file%>.js"></SCRIPT>
%}

<SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/jquery.js"></SCRIPT>

<SCRIPT TYPE="text/javascript">

  function boxon(what) {
    var $this = $(what);
    for ( var c=0; c < <%$cells%>; c++) {

      $this.css('background-color', '#ffffdd');
      if ( c == 0 ) {
        $this.css('border-top', '1px double black');
        $this.css('border-left', '1px double black');
        $this.css('border-right', '1px solid black');
      } else if ( c == <%$cells-1%> ) {
        $this.css('border-left', '1px double black');
        $this.css('border-right', '1px solid black');
        $this.css('border-bottom', '1px solid black');
      } else {
        $this.css('border-left', '1px double black');
        $this.css('border-right', '1px solid black');
      }

      var rownum = $this.parent().prevAll('tr').length;
      var colnum = $this.prevAll('td').length;
      $this = $this.parent().parent().children('tr').eq(rownum+1).children('td').eq(colnum);
    }
  }

  function boxoff(what) {
    var $this = $(what);
    for ( var c=0; c < <%$cells%>; c++) {

      //$this.css('background-color', '');
      //$this.css('border', ''); //IE8 woes, removes cell borders
      $this.removeAttr('style'); //slightly "flashy" on cell changes under IE8
                                 //but at least it doesn't remove cell borders

      var rownum = $this.parent().prevAll('tr').length;
      var colnum = $this.prevAll('td').length;
      $this = $this.parent().parent().children('tr').eq(rownum+1).children('td').eq(colnum);
    }
  }

</SCRIPT>

<& /Search/Calendar.html,
     @_,
     Query       => "( Status = 'new' OR Status = 'open' OR Status = 'stalled')
                     AND ( Type = 'reminder' OR 'Type' = 'ticket' )",
                    #XXX and we have the magic custom field
     slots       => scalar(@usernames),
     Embed       => 'Schedule.html',
     DimPast     => 1,
     Display     => 'Schedule',
     DisplayArgs => [ username  => \@usernames,
                      LengthMin => $LengthMin,
                      #oops, more freeside abstraction-leaking
                      custnum   => $ARGS{custnum},
                      pkgnum    => $ARGS{pkgnum},
                    ],
&>

<%ONCE>

my $timestep =  RT->Config->Get('CalendarWeeklySizeMin') || 30; #1/2h

</%ONCE>
<%init>

my @files = ();
#if ( ! $initialized ) {
  push @files, map "overlibmws$_", ( '', qw( _iframe _draggable _crossframe ) );
  push @files, map { "${_}contentmws" } qw( iframe ajax );
#%}

my @usernames = ();
if ( ref($ARGS{username}) ) {
  @usernames = @{ $ARGS{username} };
} elsif ( $ARGS{username} ) {
  @usernames = ( $ARGS{username} );
} else {
  #XXX shouldn't even get offered the link in the first place rather than perl
  # barf, but this is better than erroring out later or empty @username
  die "Can't schedule an appointment - no employees are configured as installers";
}

( my $LengthMin = $ARGS{LengthMin} ) =~ /^\d+$/ or die 'non-numeric LengthMin';

my $cells = int($LengthMin / $timestep);
$cells++ if $LengthMin % $timestep;

</%init>