checkpoint
[freeside.git] / fs_selfservice / fri / modules / dashboard.module
1 <?php
2
3 /**
4  * @file
5  * Functions for the interface to the help page
6  */
7
8 /**
9   * Class for help
10   */
11 class dashboard {
12
13   /*
14    * rank (for prioritizing modules)
15    */
16   function rank() {
17
18     $rank = -4;
19     return $rank;
20   }
21
22   /*
23    * init
24    */
25   function init() {
26   }
27
28   /*
29    * Adds menu item to nav menu
30    *
31    * @param $args
32    *   Common arguments
33    */
34   function navMenu($args) {
35
36     $ret .= "<p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=dashboard&f=display'>" . _("Dashboard") . "</a></small></small></p><br>";
37
38     return $ret;
39   }
40
41   /*
42    * Displays stats page
43    *
44    * @param $args
45    *   Common arguments
46    */
47   function display($args) {
48
49     $display = new Display();
50
51     // args
52     $m = getArgument($args,'m');
53     $q = getArgument($args,'q');
54
55     $displayname = $_SESSION['ari_user']['displayname'];
56     $extension = $_SESSION['ari_user']['extension'];
57
58     // build page content
59     $ret .= checkErrorMessage();
60
61         $header_text = _("Dashboard");
62         if (!$_SESSION['ari_user']['admin_help']) {
63                 $header_text .= sprintf(_(" for %s (%s)"), $displayname, $extension);
64         }
65
66     // build page content
67     $ret .= checkErrorMessage();
68
69     $ret .= $display->displayHeaderText($header_text);
70     $ret .= $display->displayLine();
71
72     $freeside = new FreesideSelfService();
73     $fs_info = $freeside->customer_info( array(
74       'session_id' => $_SESSION['freeside_session_id'],
75     ) );
76     $error = $fs_info['error'];
77     if ( $error ) {
78       //$_SESSION['ari_error'] = _("Incorrect Username or Password");
79       $_SESSION['ari_error'] = $error; #// XXX report as ari_error???!
80     }
81
82     $ret .= $fs_info['small_custview'];
83     $ret .= '<BR>';
84     
85     if ( $fs_info['balance'] > 0 ) {
86   
87       $ret .= '<B><A HREF="'. $_SESSION['ARI_ROOT'].
88               '?m=billing&f=make_payment">Make a payment</A></B><BR><BR>';
89
90     }
91
92     // XXX count() ???
93     if ( count($fs_info['open_invoices']) ) {
94   
95       $ret .= '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 BGCOLOR="#eeeeee">'.
96               '<TR><TH BGCOLOR="#ff6666" COLSPAN=5>Open Invoices</TH></TR>';
97       $link = '<A HREF="'. $_SESSION['ARI_ROOT'].
98               '?m=billing&f=view_invoice&invnum=';
99       
100       $col1 = "eeeeee";
101       $col2 = "cccccc";
102       $col = $col1;
103   
104       while ( $i = each($fs_info['open_invoices']) ) {
105   
106         $invoice = $i[value];
107   
108         $td = '<TD BGCOLOR="#'. $col. '">';
109         $a  = $link. $invoice['invnum']. '">';
110         $ret .=
111           "<TR>$td$a". 'Invoice #'. $invoice['invnum']. "</A></TD>$td</TD>".
112           "$td$a". $invoice['date']. "</A></TD>$td</TD>".
113           '<TD BGCOLOR="#'. $col. '" ALIGN="right">'. $a. '$'. $invoice['owed'].
114             '</A></TD>'.
115           '</TR>';
116
117         if ( $col == $col1 ) {
118           $col = $col2;
119         } else {
120           $col = $col1;
121         }
122
123       }
124
125       $ret .= '</TABLE><BR>';
126     } else {
127       $ret .= 'You have no outstanding invoices.<BR><BR>';
128     }
129
130     $ret .= 'Received calls (10)<br><br>';
131     $ret .= 'Placed calls (10)';
132
133 //    if ( @tickets ) {
134 //      $OUT .= '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 BGCOLOR="#eeeeee">'.
135 //              '<TR><TH BGCOLOR="#ff6666" COLSPAN=5>Open Tickets</TH></TR>'.
136 //              '<TR><TH>#</TH><TH>Subject</TH><TH>Priority</TH><TH>Queue</TH>'.
137 //              '<TH>Status</TH></TR>';
138 //      my $col1 = "ffffff";
139 //      my $col2 = "dddddd";
140 //      my $col = $col1;
141 //  
142 //      foreach my $ticket ( @tickets ) {
143 //        my $td = qq!<TD BGCOLOR="#$col">!;
144 //        $OUT .=
145 //          "<TR>$td". $ticket->{'id'}. "</TD>".
146 //          $td. $ticket->{'subject'}. "</TD>".
147 //          $td. ($ticket->{'content'} || $ticket->{'priority'}). "</TD>".
148 //          $td. $ticket->{'name'}. "</TD>".
149 //          $td. $ticket->{'status'}. "</TD>".
150 //          '</TR>';
151 //        $col = $col eq $col1 ? $col2 : $col1;
152 //      }
153 //      $OUT .= '</TABLE>';
154 //    } else {
155 //      $OUT .= '';
156 //    }
157
158     return $ret;
159   }
160
161 }
162
163 ?>