5 * Functions for the interface to the help page
14 * rank (for prioritizing modules)
29 * Adds menu item to nav menu
34 function navMenu($args) {
36 $ret .= "<p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=billing&f=display'>" . _("Billing") . "</a></small></small></p><br>";
47 function display($args) {
49 $display = new Display();
52 $m = getArgument($args,'m');
53 $q = getArgument($args,'q');
55 $displayname = $_SESSION['ari_user']['displayname'];
56 $extension = $_SESSION['ari_user']['extension'];
59 $ret .= checkErrorMessage();
61 $header_text = _("Billing");
62 if (!$_SESSION['ari_user']['admin_help']) {
63 $header_text .= sprintf(_(" for %s (%s)"), $displayname, $extension);
67 $ret .= checkErrorMessage();
69 $ret .= $display->displayHeaderText($header_text);
70 $ret .= $display->displayLine();
73 $freeside = new FreesideSelfService();
75 $fs_info = $freeside->customer_info( array(
76 'session_id' => $_SESSION['freeside_session_id'],
78 $error = $fs_info['error'];
80 //$_SESSION['ari_error'] = _("Incorrect Username or Password");
81 $_SESSION['ari_error'] = $error; #// XXX report as ari_error???!
84 //$ret .= $fs_info['small_custview'];
87 $ret .= 'Balance: <b>$'. $fs_info['balance']. '</b><BR><BR>';
89 if ( $fs_info['balance'] > 0 ) {
91 #$ret .= '<B><A HREF="'. $_SESSION['ARI_ROOT'].
92 # '?m=billing&f=make_payment">Make a payment</A></B><BR><BR>';
93 $ret .= '<B><A HREF="/selfservice/selfservice.cgi?session='.
94 $_SESSION['freeside_session_id'].
95 ';action=make_payment">Make a payment</A></B><BR><BR>';
100 if ( count($fs_info['open_invoices']) ) {
102 $ret .= '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 BGCOLOR="#eeeeee">'.
103 '<TR><TH BGCOLOR="#ff6666" COLSPAN=5>Open Invoices</TH></TR>';
104 $link = '<A HREF="'. $_SESSION['ARI_ROOT'].
105 '?m=billing&f=view_invoice&invnum=';
111 while ( $i = each($fs_info['open_invoices']) ) {
113 $invoice = $i[value];
115 $td = '<TD BGCOLOR="#'. $col. '">';
116 $a = $link. $invoice['invnum']. '">';
118 "<TR>$td$a". 'Invoice #'. $invoice['invnum']. "</A></TD>$td</TD>".
119 "$td$a". $invoice['date']. "</A></TD>$td</TD>".
120 '<TD BGCOLOR="#'. $col. '" ALIGN="right">'. $a. '$'. $invoice['owed'].
124 if ( $col == $col1 ) {
132 $ret .= '</TABLE><BR>';
134 $ret .= 'You have no outstanding invoices.<BR><BR>';
137 #$fs_info = $freeside->customer_info( array(
138 # 'session_id' => $_SESSION['freeside_session_id'],
140 #$error = $fs_info['error'];
142 # //$_SESSION['ari_error'] = _("Incorrect Username or Password");
143 # $_SESSION['ari_error'] = $error; #// XXX report as ari_error???!
146 // $ret .= 'Billing goes here';
147 // XXX navigate to make payment, view invoice,
148 // & myaccount change payment info
150 $ret .= '<B><A HREF="/selfservice/selfservice.cgi?session='.
151 $_SESSION['freeside_session_id'].
152 ';action=make_payment">Make a credit card payment</A></B><BR><BR>';
153 $ret .= '<B><A HREF="/selfservice/selfservice.cgi?session='.
154 $_SESSION['freeside_session_id'].
155 ';action=make_payment">Make an electronic check payment</A></B><BR><BR>';
156 $ret .= '<B><A HREF="/selfservice/selfservice.cgi?session='.
157 $_SESSION['freeside_session_id'].
158 ';action=make_payment">Use a prepaid card</A></B><BR><BR>';
164 function make_payment($args) {
166 $display = new Display();
169 $m = getArgument($args,'m');
170 $q = getArgument($args,'q');
172 $displayname = $_SESSION['ari_user']['displayname'];
173 $extension = $_SESSION['ari_user']['extension'];
175 // build page content
176 $ret .= checkErrorMessage();
178 $header_text = _("Billing");
179 if (!$_SESSION['ari_user']['admin_help']) {
180 $header_text .= sprintf(_(" for %s (%s)"), $displayname, $extension);
183 // build page content
184 $ret .= checkErrorMessage();
186 $ret .= $display->displayHeaderText($header_text);
187 $ret .= $display->displayLine();
190 #$freeside = new FreesideSelfService();
192 $ret .= 'Make payment goes here';
198 function view_invoice($args) {
200 $display = new Display();
203 $m = getArgument($args,'m');
204 $q = getArgument($args,'q');
206 $displayname = $_SESSION['ari_user']['displayname'];
207 $extension = $_SESSION['ari_user']['extension'];
209 // build page content
210 $ret .= checkErrorMessage();
212 $header_text = _("Billing");
213 if (!$_SESSION['ari_user']['admin_help']) {
214 $header_text .= sprintf(_(" for %s (%s)"), $displayname, $extension);
217 // build page content
218 $ret .= checkErrorMessage();
220 $ret .= $display->displayHeaderText($header_text);
221 #$ret .= $display->displayLine();
223 $invnum = getArgument($args, 'invnum');
225 $freeside = new FreesideSelfService();
226 $invoice = $freeside->invoice( array(
227 'session_id' => $_SESSION['freeside_session_id'],
230 $error = $invoice['error'];
232 //$_SESSION['ari_error'] = _("Incorrect Username or Password");
233 $_SESSION['ari_error'] = $error; // XXX report as ari_error???!
236 $html = $invoice['invoice_html']->scalar;
237 $html = str_replace( "\xA0", ' ', $html); // XX doh
240 $ret .= '<TABLE BGCOLOR="#000000" BORDER=0><TR><TD>'.
242 '</TD></TR></TABLE>';