split service level screen into parts, use buttons for gold/silver upgrades
[raven.git] / apps / gacksadmin / user_service_level.php
1 <?php
2 \r
3 // Require login\r
4 require_once 'plc_login.php';\r
5 \r
6 // Get session and API handles\r
7 require_once 'plc_session.php';\r
8 global $plc, $api, $adm;\r
9 \r
10 // Common functions\r
11 require_once 'plc_functions.php';\r
12 require_once 'gacks_functions.php';\r
13 require_once 'linetabs.php';\r
14 require_once 'table.php';\r
15 require_once 'gacksclient.php';\r
16 require_once 'toggle.php';\r
17 require_once 'details.php';\r
18 \r
19 // find person roles\r
20 $_person= $plc->person;\r
21 $_person_id = $plc->person['person_id'];\r
22 $_roles= $_person['role_ids'];
23
24 // Print header
25 require_once 'plc_drupal.php';\r
26 drupal_set_title('Service Level');\r
27 include 'plc_header.php';\r
28 \r
29 $gacksapi = new GACKSAPI();\r
30 \r
31 $toggle = new PlekitToggle ('select_sice',"Select slice",\r
32                             array('bubble'=>'Select slice to configure',\r
33                                   'visible'=>true));\r
34 \r
35 $toggle->start();\r
36 \r
37 print "<br>";\r
38 \r
39 $account_name = get_account_name($api, $_person_id);\r
40 \r
41 $account = NULL;\r
42 if ($account_name != NULL) {\r
43     $account = $gacksapi->get_account(gacksid($account_name), "user", True);\r
44 }\r
45 \r
46 if ($account == NULL) {\r
47     if ($account_name != NULL) {\r
48         print "Oops. We had an error retrieving the account details for $account_name.";\r
49     }\r
50     $toggle->end();\r
51 } else {\r
52     $account = $gacksapi->get_account(gacksid($account_name), "user");\r
53     $level = $account['level'];\r
54 \r
55     if ($level == "default") {\r
56         $level = "best effort";\r
57     }\r
58 \r
59     print "<br><p>Your current service level is <span class='bold'>$level</span>. </p>";\r
60 \r
61 //    $details = new PlekitDetails($can_update);\r
62 //    $details->start();\r
63 //    $details->th_td("Service Level", $level);\r
64 //    $details->end();\r
65 \r
66     $toggle->end();\r
67 \r
68     if ($level != "gold") {\r
69         $toggle = new PlekitToggle ('upgrade',"Upgrade Service",\r
70                                     array('bubble'=>'Upgrade service to allow reservations',\r
71                                           'visible'=>get_arg('upgrade_service',true)));\r
72 \r
73         $toggle->start();\r
74 \r
75         print <<< EOF\r
76 <p>You may upgrade your service level to silver or gold access in order to be able to reserve resources.\r
77 Silver or gold access will incur a membership fee, and require a one year commitment. To read more\r
78 about the policies associated with silver or gold access, please follow these links:\r
79 <a href="/service_silver">silver</a> or <a href="/service_gold">gold</a>.</p>\r
80 <p>To upgrade your service, choose a new service level below:</p>\r
81 EOF;\r
82         if ($level != "silver") {\r
83             $form = new PlekitForm(l_gacks_actions(), array("action" => "set-service",\r
84                                                           "account_name" => $account_name,\r
85                                                           "level" => "silver"));\r
86             $form->start();\r
87             print $form->submit_html("submit", "Upgrade To Silver");\r
88             $form->end();\r
89 \r
90             print "<br>";\r
91         }\r
92 \r
93 \r
94         $form = new PlekitForm(l_gacks_actions(), array("action"=>"set-service",\r
95                                                       "account_name" => $account_name,\r
96                                                       "level" => "gold"));\r
97         $form->start();\r
98         print $form->submit_html("submit", "Upgrade To Gold");\r
99         $form->end();\r
100 \r
101         $toggle->end();\r
102     }\r
103 \r
104     // --------------------- service settings ------------------------------------\r
105 \r
106     $toggle = new PlekitToggle ("service_settings", "Service Settings",\r
107                                 array('bubble'=>'Configure Service Settings',\r
108                                       'visible'=>get_arg('service_settings',true)));\r
109 \r
110     $toggle->start();\r
111 \r
112     $form = new PlekitForm(l_gacks_actions(), array("action"=>"set-service",\r
113                                                     "account_name"=> $account_name));
114     $form->start();\r
115 \r
116     if ($level != "best effort") {\r
117         $term = $account['term'];\r
118         if ($term == "") {\r
119             $term = 0;\r
120         }\r
121 \r
122         $anniversary = new DateTime();\r
123         $anniversary->setTimestamp(intval($account['serviceStartDate']));\r
124         $anniversary->add(new DateInterval("P" . $term . "M"));\r
125         $anniversary = $anniversary->format("Y-m-d");\r
126 \r
127         $renew_selectors = array();\r
128         $renew_selectors []= array("display"=>"Automatically renew service", "value"=>"1", "selected"=>$account['autoRenew']);\r
129         $renew_selectors []= array("display"=>"Do not automatically renew", "value"=>"0", "selected"=>!$account['autoRenew']);\r
130         $renew_combo = $form->select_html("autoRenew", $renew_selectors);\r
131 \r
132         $freeze_selectors = array();\r
133         $freeze_selectors []= array("display"=>"Allow best effort slivers", "value"=>"1", "selected"=>!$account['freezeUnreserved']);\r
134         $freeze_selectors []= array("display"=>"Prevent best effort slivers", "value"=>"0", "selected"=>$account['freezeUnreserved']);\r
135         $freeze_combo = $form->select_html("enableBestEffort", $freeze_selectors);\r
136 \r
137         print <<< EOF\r
138 <br><p>You may choose whether or not your service will\r
139 automatically renew. The next renewal date of your service is $anniversary and it will renew for $term months.</p>\r
140 <p>Choose an automatic renewal option below:</p>\r
141 $renew_combo\r
142 \r
143 <br><p>Reservation users can choose whether or not to enable best effort traffic. If best effort traffic is\r
144 enabled, then Vicci will allow your slices to run on nodes even though you have not reserved them. Regulard best\r
145 effort changes will apply. Vicci may be configured to automatically freeze your slices if no reservation is present,\r
146 preventing best effort charges from being incurred.</p>\r
147 $freeze_combo\r
148 EOF;\r
149     }\r
150 \r
151     print <<< EOF\r
152 <br><p>Please enter the email addresses of your billing contacts below.\r
153 You may enter multiple contacts separated by a comma. Invoices will be emailed\r
154 to these contacts once per week</p>\r
155 EOF;\r
156     print $form->input_html("text", "billingContacts", $account['billingContacts'], array("size"=>"80"));\r
157 \r
158     print "<br><br>";\r
159     print $form->submit_html("submit", "submit");\r
160 \r
161     $form->end();\r
162 \r
163     $toggle->end();\r
164 }\r
165 \r
166 include 'plc_footer.php';\r
167 \r
168 ?>
169