This commit was generated by cvs2svn to compensate for changes in r11022,
[freeside.git] / fs_selfservice / fri / modules / featurecodes.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 featurecodes {
12
13   /*
14    * rank (for prioritizing modules)
15    */
16   function rank() {
17
18     $rank = 7;
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=featurecodes&f=display'>" . _("Feature Codes") . "</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 = _("Feature Codes");
64         if (!$_SESSION['ari_user']['admin_help']) {
65                 $header_text .= sprintf(_(" for %s (%s)"), $displayname, $extension);
66         }
67
68     // handset feature code header
69     $handset_feature_codes_header =
70       "<tr>
71          <th class='feature_codes'>
72            " . _("Handset Feature Code") . "
73          </th>
74          <th>
75            " . _("Action") . "
76          </th>
77        </tr>";
78
79     // handset feature code body
80     if (isset($_SESSION['dbh_asterisk'])) {
81
82       $sql = "
83              SELECT keycode, description
84              FROM (
85                SELECT modulename, description, defaultcode keycode
86                FROM featurecodes 
87                WHERE customcode IS NULL 
88                AND enabled = '1'
89                UNION ALL SELECT modulename, description, customcode keycode
90                FROM featurecodes
91                WHERE customcode IS NOT NULL 
92                AND enabled = '1'
93              )c
94              WHERE modulename NOT 
95              IN ( 'core', 'recordings', 'infoservices', 'polycomreassign')
96              ORDER BY modulename, keycode
97              ";
98
99                 $results = $_SESSION['dbh_asterisk']->getAll($sql, DB_FETCHMODE_ASSOC);
100                 if(DB::IsError($results)) {
101                         $_SESSION['ari_error'] = $results->getMessage();
102                 }
103                 else {
104                         foreach ($results as $item ) {
105                                 $handset_feature_codes_body .= 
106                                         "<tr>
107                                         <td class='feature_codes'>
108                                         " . $item['keycode'] . "
109                                         </td>
110                                         <td>
111                                         " . $item['description'] . "
112                                         </td>
113                                         </tr>";
114                         }
115                 }
116     }
117     else {
118
119       // handset feature code body
120       foreach($ARI_HELP_FEATURE_CODES as $key => $feature_code) {
121
122         $handset_feature_codes_body .= 
123           "<tr>
124              <td class='feature_codes'>
125                " . $key . "
126              </td>
127              <td>
128                " . $feature_code . "
129              </td>
130            </tr>";
131       }
132     }
133
134     // build page content
135     $ret .= checkErrorMessage();
136
137     $ret .= $display->displayHeaderText($header_text);
138     $ret .= $display->displayLine();
139
140     // table 
141     $ret .= "
142       <table class='help'>
143         " . $handset_feature_codes_header . "
144         " . $handset_feature_codes_body . "
145       </table>";
146
147     return $ret;
148   }
149
150 }
151
152 ?>