change title of summary page; remove windows linefeeds
smbaker [Sat, 3 Nov 2012 03:01:57 +0000 (20:01 -0700)]
apps/gacksadmin/gacks_functions.php
apps/gacksadmin/user_summary.php

index 77d1e88..003ddf6 100644 (file)
@@ -107,7 +107,7 @@ function level_selectors($value)
 {
     $level_selectors = array();
     $level_selectors []= array("display"=>"Default", "value"=>"default");
-    $level_selectors []= array("display"=>"Silver", "value"=>"silver");\r
+    $level_selectors []= array("display"=>"Silver", "value"=>"silver");
     $level_selectors []= array("display"=>"Gold", "value"=>"gold");
 
     foreach ($level_selectors as &$sel) {
@@ -156,7 +156,7 @@ function bool_selectors($value)
 
     $bool_selectors = array();
     $bool_selectors []= array("display"=>"Yes", "value"=>"1");
-    $bool_selectors []= array("display"=>"No", "value"=>"0");\r
+    $bool_selectors []= array("display"=>"No", "value"=>"0");
 
     foreach ($bool_selectors as &$sel) {
         if ($sel["value"] == $value) {
@@ -193,54 +193,54 @@ function aggregate_records($records)
 function record_table($records, $timezone_seconds)
 {
     $headers=array();
-    $headers["id"] = "string";\r
-    $headers["start"] = "string";\r
-    $headers["stop"] = "string";\r
-    $headers["lastAllocator"] = "string";\r
-    $headers["consumer"] = "string";\r
-    $headers["qty"] = "int";\r
-    $headers["actions"] = "string";\r
-\r
-    $sort_column = 1;\r
-    $table = new PlekitTable("reservations", $headers, $sort_column);\r
-    $table->start();\r
-\r
-    $aggs = aggregate_records($records);\r
-\r
-    foreach ( $aggs as $item ) {\r
-            $table->row_start();\r
-            $table->cell($item['id']);\r
-            $table->cell(strftime("%Y-%m-%d %H:%M:%S", $item['timeStart']+$timezone_seconds));\r
-            $table->cell(strftime("%Y-%m-%d %H:%M:%S", $item['timeStop']+$timezone_seconds));\r
-            $table->cell(end($item['allocatorHRNs']));\r
-            $table->cell($item['consumerHRN']);\r
-            $table->cell($item['qty']);\r
-            $table->cell(href(l_gacks_delete($item), "delete")); // href(l_gacks_edit($item), "edit") . " "\r
-            $table->row_end();\r
-    }\r
-\r
+    $headers["id"] = "string";
+    $headers["start"] = "string";
+    $headers["stop"] = "string";
+    $headers["lastAllocator"] = "string";
+    $headers["consumer"] = "string";
+    $headers["qty"] = "int";
+    $headers["actions"] = "string";
+
+    $sort_column = 1;
+    $table = new PlekitTable("reservations", $headers, $sort_column);
+    $table->start();
+
+    $aggs = aggregate_records($records);
+
+    foreach ( $aggs as $item ) {
+            $table->row_start();
+            $table->cell($item['id']);
+            $table->cell(strftime("%Y-%m-%d %H:%M:%S", $item['timeStart']+$timezone_seconds));
+            $table->cell(strftime("%Y-%m-%d %H:%M:%S", $item['timeStop']+$timezone_seconds));
+            $table->cell(end($item['allocatorHRNs']));
+            $table->cell($item['consumerHRN']);
+            $table->cell($item['qty']);
+            $table->cell(href(l_gacks_delete($item), "delete")); // href(l_gacks_edit($item), "edit") . " "
+            $table->row_end();
+    }
+
     $table->end();
 }
 
 function charge_detail($charge)
 {
     $details = new PlekitDetails(False);
-\r
-    $details->start();\r
-\r
-    $details->form_start(l_gacks_actions(), array());\r
-\r
-    $details->th_td("id", $charge["id"]);\r
-    $details->th_td("object/desc", $charge["object_desc"]);\r
-    $details->th_td("kind", $charge["kind_id"]);\r
-    $details->th_td("date", $charge["date"]);\r
-    $details->th_td("amount", $charge["amount"]);\r
-    $details->th_td("state", $charge["state"]);\r
-    $details->th_td("parent_id", $charge["parent_id"]);\r
-    $details->th_td("account_name", $charge["account_name"]);\r
-\r
-    $details->end();\r
-    $details->form_end();\r
+
+    $details->start();
+
+    $details->form_start(l_gacks_actions(), array());
+
+    $details->th_td("id", $charge["id"]);
+    $details->th_td("object/desc", $charge["object_desc"]);
+    $details->th_td("kind", $charge["kind_id"]);
+    $details->th_td("date", $charge["date"]);
+    $details->th_td("amount", $charge["amount"]);
+    $details->th_td("state", $charge["state"]);
+    $details->th_td("parent_id", $charge["parent_id"]);
+    $details->th_td("account_name", $charge["account_name"]);
+
+    $details->end();
+    $details->form_end();
 }
 
 function dollars($amount)
@@ -261,95 +261,95 @@ function invoice_table($invoice, $account_name, $account_token, $options)
     $invoice_kind[KIND_PAYMENT] = "payment";
 
     $headers=array();
-    $headers["id"] = "string";\r
-    $headers["account_name"] = "string";\r
-    $headers["date"] = "string";\r
-    $headers["kind"] = "string";\r
-    $headers["description"] = "string";\r
-    $headers["amount"] = "int";\r
-\r
-    // ideally it would be nice if we could sort by 3 columns,\r
-    //    account_name, date, description\r
-    if ($account_name) {\r
-        $sort_column = 2; // date\r
-    } else {\r
-        $sort_column = 1; // account name\r
-    }\r
-\r
-    $table = new PlekitTable("invoices", $headers, $sort_column);\r
-    $table->start();\r
-\r
-    $charges = $invoice['charges'];\r
-\r
-    foreach ( $charges as $item ) {\r
-            //if ($options['date_only']) {\r
-            if (is_time_unimportant($item['kind_id'])) {\r
-                $date = explode(' ', $item['date']);\r
-                $date = $date[0];\r
-            } else {\r
-                $date = $item['date'];\r
-            }\r
-            $table->row_start();\r
-            $table->cell(href(l_gacks_invoice($account_name, $account_token, NULL, NULL, NULL, $item['id']), $item['id']));\r
-            $table->cell($item['account_name']);\r
-            $table->cell($date);\r
-            $table->cell($invoice_kind[$item['kind_id']]);\r
-            $table->cell($item['object_desc']);\r
-            $table->cell(dollars($item['amount']), array("align"=>"right"));\r
-            $table->row_end();\r
-    }\r
-\r
+    $headers["id"] = "string";
+    $headers["account_name"] = "string";
+    $headers["date"] = "string";
+    $headers["kind"] = "string";
+    $headers["description"] = "string";
+    $headers["amount"] = "int";
+
+    // ideally it would be nice if we could sort by 3 columns,
+    //    account_name, date, description
+    if ($account_name) {
+        $sort_column = 2; // date
+    } else {
+        $sort_column = 1; // account name
+    }
+
+    $table = new PlekitTable("invoices", $headers, $sort_column);
+    $table->start();
+
+    $charges = $invoice['charges'];
+
+    foreach ( $charges as $item ) {
+            //if ($options['date_only']) {
+            if (is_time_unimportant($item['kind_id'])) {
+                $date = explode(' ', $item['date']);
+                $date = $date[0];
+            } else {
+                $date = $item['date'];
+            }
+            $table->row_start();
+            $table->cell(href(l_gacks_invoice($account_name, $account_token, NULL, NULL, NULL, $item['id']), $item['id']));
+            $table->cell($item['account_name']);
+            $table->cell($date);
+            $table->cell($invoice_kind[$item['kind_id']]);
+            $table->cell($item['object_desc']);
+            $table->cell(dollars($item['amount']), array("align"=>"right"));
+            $table->row_end();
+    }
+
     $table->end();
 }
 
 # from http://cool-php-tutorials.blogspot.com/2010/02/easy-php-date-picker.html
-function date_picker($name, $y, $m, $d)\r
-{\r
-    $startyear = 2012;\r
-    $endyear = date("Y");\r
-\r
-    $months=array('','January','February','March','April','May',\r
-    'June','July','August', 'September','October','November','December');\r
-\r
-    // Month dropdown\r
-    $html="<select name=\"".$name."month\">";\r
-\r
-    for($i=1;$i<=12;$i++)\r
-    {\r
-       $html.="<option value='$i'";\r
-       if ($i==$m) {\r
-           $html.=" selected=true";\r
-       }\r
-       $html.=">$months[$i]</option>";\r
-    }\r
-    $html.="</select> ";\r
-\r
-    // Day dropdown\r
-    $html.="<select name=\"".$name."day\">";\r
-    for($i=1;$i<=31;$i++)\r
-    {\r
-       $html.="<option value='$i'";\r
-       if ($i==$d) {\r
-           $html.=" selected=true";\r
-       }\r
-       $html.=">$i</option>";\r
-    }\r
-    $html.="</select> ";\r
-\r
-    // Year dropdown\r
-    $html.="<select name=\"".$name."year\">";\r
-\r
-    for($i=$startyear;$i<=$endyear;$i++)\r
-    {\r
-      $html.="<option value='$i'";\r
-      if ($i==$y) {\r
-          $html.=" selected=true";\r
-      }\r
-      $html.=">$i</option>";\r
-    }\r
-    $html.="</select> ";\r
-\r
-    return $html;\r
+function date_picker($name, $y, $m, $d)
+{
+    $startyear = 2012;
+    $endyear = date("Y");
+
+    $months=array('','January','February','March','April','May',
+    'June','July','August', 'September','October','November','December');
+
+    // Month dropdown
+    $html="<select name=\"".$name."month\">";
+
+    for($i=1;$i<=12;$i++)
+    {
+       $html.="<option value='$i'";
+       if ($i==$m) {
+           $html.=" selected=true";
+       }
+       $html.=">$months[$i]</option>";
+    }
+    $html.="</select> ";
+
+    // Day dropdown
+    $html.="<select name=\"".$name."day\">";
+    for($i=1;$i<=31;$i++)
+    {
+       $html.="<option value='$i'";
+       if ($i==$d) {
+           $html.=" selected=true";
+       }
+       $html.=">$i</option>";
+    }
+    $html.="</select> ";
+
+    // Year dropdown
+    $html.="<select name=\"".$name."year\">";
+
+    for($i=$startyear;$i<=$endyear;$i++)
+    {
+      $html.="<option value='$i'";
+      if ($i==$y) {
+          $html.=" selected=true";
+      }
+      $html.=">$i</option>";
+    }
+    $html.="</select> ";
+
+    return $html;
 }
 
 function get_slices($plcapi, $person_id, $fields)
@@ -359,28 +359,28 @@ function get_slices($plcapi, $person_id, $fields)
     }
 
     $persons = $plcapi->GetPersons(array('person_id'=>$person_id),array('person_id','email','slice_ids','role_ids','site_ids'));
-    $person=$persons[0];\r
-    $slice_filter=array('slice_id' => $person['slice_ids']);\r
-    $user_slices=$plcapi->GetSlices($slice_filter,$fields);\r
-\r
-    $slices = array();\r
-    foreach ($user_slices as $slice) {\r
-        $slices[$slice['name']] = $slice;\r
-    }\r
-\r
-    $is_pi = in_array( 20, $person['role_ids']);\r
-    if ($is_pi) {\r
-        $slice_filter=array('site_id'=>$person['site_ids'][0]);\r
-        $pi_slices = $plcapi->GetSlices($slice_filter, $fields);\r
-\r
-        foreach ($pi_slices as $slice) {\r
-            if (!array_key_exists($slice['name'], $slices)) {\r
-                $slices[$slice['name']] = $slice;\r
-            }\r
-        }\r
-    }\r
-\r
-    return $slices;\r
+    $person=$persons[0];
+    $slice_filter=array('slice_id' => $person['slice_ids']);
+    $user_slices=$plcapi->GetSlices($slice_filter,$fields);
+
+    $slices = array();
+    foreach ($user_slices as $slice) {
+        $slices[$slice['name']] = $slice;
+    }
+
+    $is_pi = in_array( 20, $person['role_ids']);
+    if ($is_pi) {
+        $slice_filter=array('site_id'=>$person['site_ids'][0]);
+        $pi_slices = $plcapi->GetSlices($slice_filter, $fields);
+
+        foreach ($pi_slices as $slice) {
+            if (!array_key_exists($slice['name'], $slices)) {
+                $slices[$slice['name']] = $slice;
+            }
+        }
+    }
+
+    return $slices;
 }
 
 function get_account_names($plcapi, $person_id)
@@ -576,16 +576,16 @@ function account_table($plcapi, $gacksapi, $person_id)
     }
 
     $headers=array();
-    $headers["name"] = "string";\r
-    $headers["level"] = "string";\r
-    $headers["be"] = "string";\r
-    $headers["users"] = "integer";\r
-    $headers["slivers"] = "integer";\r
-    $headers["billingContacts"] = "string";\r
-\r
-    $table = new PlekitTable("accounts", $headers, 0);\r
-    $table->start();\r
-\r
+    $headers["name"] = "string";
+    $headers["level"] = "string";
+    $headers["be"] = "string";
+    $headers["users"] = "integer";
+    $headers["slivers"] = "integer";
+    $headers["billingContacts"] = "string";
+
+    $table = new PlekitTable("accounts", $headers, 0);
+    $table->start();
+
     foreach ($accounts as $name => $account) {
         $slice = $slices[$name];
         $table->row_start();
@@ -676,26 +676,26 @@ function time_selectors($start_date, $min_date)
 function get_timezone()
 {
     if (isset($_GET['timezone_offset_minutes'])) {
-        $minutes = $_GET['timezone_offset_minutes'];\r
-/*        echo "GMT offset (in minutes, from the browser): ". $minutes ."<br />\n";\r
-        echo "GMT: ". gmdate("Y-m-d H:i:s") ."<br />\n";\r
-\r
-        $local = gmmktime(gmdate("H"),gmdate("i")-$minutes); // adjust GMT by client's offset\r
-\r
-        echo "Calculated client's date/time: ". gmdate("Y-m-d h:i:s a",$local) ."<br />\n";*/\r
-\r
-        return $minutes;\r
-    } else {\r
-        if  (!strchr($_SERVER['REQUEST_URI'], "?")) {\r
-            $url = $_SERVER['REQUEST_URI'] . "?";\r
-        } else {\r
-            $url = $_SERVER['REQUEST_URI'] . "&";\r
-        }\r
-\r
-        echo "<script language='javascript'>\n";\r
-        echo "var d = new Date();\n";\r
-        echo "location.href=\"${url}timezone_offset_minutes=\" + (-d.getTimezoneOffset());\n";\r
-        echo "</script>\n";\r
-        exit();\r
-    }\r
+        $minutes = $_GET['timezone_offset_minutes'];
+/*        echo "GMT offset (in minutes, from the browser): ". $minutes ."<br />\n";
+        echo "GMT: ". gmdate("Y-m-d H:i:s") ."<br />\n";
+
+        $local = gmmktime(gmdate("H"),gmdate("i")-$minutes); // adjust GMT by client's offset
+
+        echo "Calculated client's date/time: ". gmdate("Y-m-d h:i:s a",$local) ."<br />\n";*/
+
+        return $minutes;
+    } else {
+        if  (!strchr($_SERVER['REQUEST_URI'], "?")) {
+            $url = $_SERVER['REQUEST_URI'] . "?";
+        } else {
+            $url = $_SERVER['REQUEST_URI'] . "&";
+        }
+
+        echo "<script language='javascript'>\n";
+        echo "var d = new Date();\n";
+        echo "location.href=\"${url}timezone_offset_minutes=\" + (-d.getTimezoneOffset());\n";
+        echo "</script>\n";
+        exit();
+    }
 }
index 2ffa783..f3e9a2e 100644 (file)
@@ -1,36 +1,36 @@
 <?php
-\r
-// Require login\r
-require_once 'plc_login.php';\r
-\r
-// Get session and API handles\r
-require_once 'plc_session.php';\r
-global $plc, $api, $adm;\r
-\r
-// Common functions\r
-require_once 'plc_functions.php';\r
-require_once 'gacks_functions.php';\r
-require_once 'linetabs.php';\r
-require_once 'table.php';\r
-require_once 'gacksclient.php';\r
-\r
-// find person roles\r
-$_person= $plc->person;\r
-$_person_id = $plc->person['person_id'];\r
+
+// Require login
+require_once 'plc_login.php';
+
+// Get session and API handles
+require_once 'plc_session.php';
+global $plc, $api, $adm;
+
+// Common functions
+require_once 'plc_functions.php';
+require_once 'gacks_functions.php';
+require_once 'linetabs.php';
+require_once 'table.php';
+require_once 'gacksclient.php';
+
+// find person roles
+$_person= $plc->person;
+$_person_id = $plc->person['person_id'];
 $_roles= $_person['role_ids'];
 
 // Print header
-require_once 'plc_drupal.php';\r
-drupal_set_title('Service Level');\r
-include 'plc_header.php';\r
-\r
-$gacksapi = new GACKSAPI();\r
-\r
-print "<br><br>";\r
-\r
-account_table($api, $gacksapi, $_person_id);\r
-\r
-include 'plc_footer.php';\r
-\r
+require_once 'plc_drupal.php';
+drupal_set_title('Summary');
+include 'plc_header.php';
+
+$gacksapi = new GACKSAPI();
+
+print "<br><br>";
+
+account_table($api, $gacksapi, $_person_id);
+
+include 'plc_footer.php';
+
 ?>