first bits of working FRI! woop!
[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     global $ARI_HELP_FEATURE_CODES;
50
51     $display = new Display();
52
53     // args
54     $m = getArgument($args,'m');
55     $q = getArgument($args,'q');
56
57     $displayname = $_SESSION['ari_user']['displayname'];
58     $extension = $_SESSION['ari_user']['extension'];
59
60     // build page content
61     $ret .= checkErrorMessage();
62
63         $header_text = _("Dashboard");
64         if (!$_SESSION['ari_user']['admin_help']) {
65                 $header_text .= sprintf(_(" for %s (%s)"), $displayname, $extension);
66         }
67
68     // build page content
69     $ret .= checkErrorMessage();
70
71     $ret .= $display->displayHeaderText($header_text);
72     $ret .= $display->displayLine();
73
74     $freeside = new FreesideSelfService();
75     $fs_info = $freeside->customer_info( array(
76       'session_id' => $_SESSION['freeside_session_id'],
77     ) );
78     $error = $fs_info['error'];
79     if ( $error ) {
80       //$_SESSION['ari_error'] = _("Incorrect Username or Password");
81       $_SESSION['ari_error'] = $error; #// XXX report as ari_error???!
82     }
83
84     $ret .= $fs_info['small_custview'];
85     $ret .= '<BR>';
86     
87     if ( $fs_info['balance'] > 0 ) {
88   
89       // XXX correct URL
90       $ret .= '<B><A HREF="'. $url.
91               'make_payment">Make a payment</A></B><BR><BR>';
92
93     }
94
95     // XXX count() ???
96     if ( count($fs_info['open_invoices']) ) {
97   
98       $ret .= '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 BGCOLOR="#eeeeee">'.
99               '<TR><TH BGCOLOR="#ff6666" COLSPAN=5>Open Invoices</TH></TR>';
100       $link = '<A HREF="'. $url. 'myaccount'; // #XXX url
101       $col1 = "eeeeee";
102       $col2 = "cccccc";
103       $col = $col1;
104   
105       while ( $i = each($fs_info['open_invoices']) ) {
106   
107         $invoice = $i[value];
108   
109         $td = '<TD BGCOLOR="#'. $col. '">';
110         $a  = '<A HREF="'. $url. 'view_invoice;invnum='.
111               $invoice['invnum']. '">';
112         $ret .=
113           "<TR>$td$a". 'Invoice #'. $invoice['invnum']. "</A></TD>$td</TD>".
114           "$td$a". $invoice['date']. "</A></TD>$td</TD>".
115           '<TD BGCOLOR="#'. $col. '" ALIGN="right">'. $a. '$'. $invoice['owed'].
116             '</A></TD>'.
117           '</TR>';
118
119         if ( $col == $col1 ) {
120           $col = $col2;
121         } else {
122           $col = $col1;
123         }
124
125       }
126
127       $ret .= '</TABLE><BR>';
128     } else {
129       $ret .= 'You have no outstanding invoices.<BR><BR>';
130     }
131
132     $ret .= 'Received calls (10)<br><br>';
133     $ret .= 'Placed calls (10)';
134
135 //    if ( @tickets ) {
136 //      $OUT .= '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 BGCOLOR="#eeeeee">'.
137 //              '<TR><TH BGCOLOR="#ff6666" COLSPAN=5>Open Tickets</TH></TR>'.
138 //              '<TR><TH>#</TH><TH>Subject</TH><TH>Priority</TH><TH>Queue</TH>'.
139 //              '<TH>Status</TH></TR>';
140 //      my $col1 = "ffffff";
141 //      my $col2 = "dddddd";
142 //      my $col = $col1;
143 //  
144 //      foreach my $ticket ( @tickets ) {
145 //        my $td = qq!<TD BGCOLOR="#$col">!;
146 //        $OUT .=
147 //          "<TR>$td". $ticket->{'id'}. "</TD>".
148 //          $td. $ticket->{'subject'}. "</TD>".
149 //          $td. ($ticket->{'content'} || $ticket->{'priority'}). "</TD>".
150 //          $td. $ticket->{'name'}. "</TD>".
151 //          $td. $ticket->{'status'}. "</TD>".
152 //          '</TR>';
153 //        $col = $col eq $col1 ? $col2 : $col1;
154 //      }
155 //      $OUT .= '</TABLE>';
156 //    } else {
157 //      $OUT .= '';
158 //    }
159
160     return $ret;
161   }
162
163 }
164
165 ?>