}
            if ($has_inc) {
                //same request as above with sys_id's instead of dispaly values (used for the watchlist)
                $inc_urlwl = '/incident.do?JSONv2&sysparm_action=getRecords&sysparm_query=active=true^state!=14^caller_id.user_name=' . $user . '^ORwatch_listLIKE' . $user_id;
                $inc_jsonwl = get_SN($inc_urlwl, $args);
            }
            $item_url = '/sc_req_item.do?JSONv2&displayvalue=true&sysparm_action=getRecords&sysparm_query=active=true^state!=14^sys_created_by=' . $user . '^ORwatch_listLIKE' . $user_id . '^ORrequest.requested_for.user_name=' . $user;
            $item_json = get_SN($item_url, $args);
            $has_items = FALSE;
            if (!empty($item_json->records)) {
                $has_items = TRUE;
            }
            //Items
            if ($has_items) {
                $item_urlwl = '/sc_req_item.do?JSON&sysparm_action=getRecords&sysparm_query=active=true^state!=14^sys_created_by=' . $user . '^ORwatch_listLIKE' . $user_id . '^ORrequest.requested_for.user_name=' . $user;
                $item_jsonwl = get_SN($item_urlwl, $args);
            }
            ?>

                    <?php 
            if ($has_req || $has_inc || $has_items) {
                ?>
                    <h2 id="incident_header" class="assistive-text">Incidents</h2>
                    
                    <div class="request-list request-list-header row">
                        <span id="col_head_num" class="col-lg-2 col-md-2 col-sm-2 request-list-number hidden-xs">Number</span>
                        <span id="col_head_ser" class="col-lg-3 col-md-3 request-list-service hidden-sm hidden-xs">Service</span>
                        <span id="col_head_des" class="col-lg-4 col-md-6 col-sm-6 col-xs-4 request-list-description">Description</span>
                        <span id="col_head_sta" class="col-lg-2 col-md-2 col-sm-2 col-xs-2 request-list-status">Status</span>
                    </div>
                    
Пример #2
0
function service_status()
{
    $hash = base64_encode(get_option('uwc_SN_USER') . ':' . get_option('uwc_SN_PASS'));
    $args = array('headers' => array('Authorization' => 'Basic ' . $hash), 'timeout' => 25);
    echo "<h4>eOutages</h4><p>For more information about eOutages, visit <a href=\"https://www.washington.edu/cac/outages\">eOutage Homepage</a><p>";
    $dom = new DOMDocument();
    $eOutage = check_e_outage();
    if (!$eOutage) {
        echo "<div class='alert alert-warning' style='margin-top:2em;'>There are no eOutages.</div>";
    } else {
        $dom->loadHTML($eOutage);
        $titleArray = array();
        $dateArray = array();
        $contentArray = array();
        $eOutageTitles = $dom->getElementsByTagName('h4');
        $eOutageDates = $dom->getElementsByTagName('em');
        $eOutageContent = $dom->getElementsByTagName('div');
        foreach ($eOutageTitles as $title) {
            $titleArray[] = $title->nodeValue;
        }
        foreach ($eOutageDates as $date) {
            $dateArray[] = $date->nodeValue;
        }
        foreach ($eOutageContent as $content) {
            $contentArray[] = parse_eoutage($content->textContent);
        }
        for ($i = 0; $i < count($titleArray); $i++) {
            echo "<div class='servicecontent row'>";
            echo "<div class='servicewrap row'>";
            echo "<span class='glyphicon glyphicon-chevron-right switch' style='display:inline-block;float:left;'></span>";
            echo "<span class='service_name col-lg-5 col-md-5 col-sm-7 col-xs-7' style='font-weight:bold; display:inline-block;'>" . $titleArray[$i] . "</span>";
            echo "<span class='service_time col-lg-4 col-md-4 col-sm-4 col-xs-4' style='color:#aaa; font-size:95%; display:inline-block;'><span class='hidden-sm hidden-xs'></span>" . $dateArray[$i] . "</span>";
            echo "</div>";
            echo "<ul class='relatedincidents'>";
            echo "<li class='incident-head row'>";
            echo "<div class='col-lg-9 col-md-9 col-sm-9 col-xs-9'>Description</div>";
            echo "</li>";
            echo "<div class='col-lg-9 col-md-9 col-sm-9 col-xs-9 inc_sdesc'>" . $contentArray[$i] . "</div>";
            echo "</li></a>";
            echo "</ul>";
            echo "</div><p>";
        }
    }
    echo "</div>";
    echo "<br><h4>High Priority Incidents</h4>";
    //$JSON = get_SN('/incident_list.do?JSONv2&sysparm_query=active%3Dtrue%5EstateNOT%20IN6%2C7%5Epriority%3D2%5EORpriority%3D1%5Eu_sectorNOT%20INK20%2CPNWGP%2CPWave%5EORu_sector%3D%5Eparent_incident=NULL&displayvalue=true', $args);
    //$IDJSON = get_SN('/incident_list.do?JSONv2&sysparm_query=active%3Dtrue%5EstateNOT%20IN6%2C7%5Epriority%3D2%5EORpriority%3D1%5Eu_sectorNOT%20INK20%2CPNWGP%2CPWave%5EORu_sector%3D%5Eparent_incident%3DNULL^ORDERBYcmdb_ci', $args);
    $JSON = get_SN('/incident_list.do?JSONv2&sysparm_query=active%3Dtrue%5EstateNOT%20IN6%2C7%5Epriority%3D2%5EORpriority%3D1%5Eu_sector%3DUW%5EORu_sector%3D%5Eparent_incident=NULL^cmdb_ci.u_organizational_group%3D51af60a86f2a110054aafd16ad3ee4d0&displayvalue=true', $args);
    $IDJSON = get_SN('/incident_list.do?JSONv2&sysparm_query=active%3Dtrue%5EstateNOT%20IN6%2C7%5Epriority%3D2%5EORpriority%3D1%5Eu_sector%3DUW%5EORu_sector%3D%5Eparent_incident%3DNULL^cmdb_ci.u_organizational_group%3D51af60a86f2a110054aafd16ad3ee4d0^ORDERBYcmdb_ci', $args);
    if (!$JSON) {
        echo "<div class='alert alert-warning' style='margin-top:2em;'>We are currently experiencing problems retrieving the status of our services. Please try again in a few minutes.</div>";
    } elseif (empty($JSON->records)) {
        echo "<div class='alert alert-warning' style='margin-top:2em;'>There are no high priority incidents.</div>";
    }
    $sn_data = array();
    foreach ($IDJSON->records as $record) {
        if (!isset($sn_data[$record->cmdb_ci])) {
            $sn_data[$record->cmdb_ci] = array();
            unset($first);
        } else {
            $first = $sn_data[$record->cmdb_ci][1];
            //cannot assume order. load current first for ci
        }
        $create = $record->sys_created_on;
        if (!isset($first)) {
            $first = $create;
        }
        if ($create < $first) {
            $first = $create;
        }
        $sn_data[$record->cmdb_ci][] = $record;
        $sn_data[$record->cmdb_ci][] = $first;
    }
    $classes = array();
    foreach ($sn_data as $ci) {
        $serviceid = $ci[0]->cmdb_ci;
        $servJSON = get_SN('/cmdb_ci_list.do?JSONv2&sysparm_query=u_active!%3Dfalse%5Esys_id%3D' . $serviceid . '&displayvalue=true', $args);
        $class = $servJSON->records[0]->sys_class_name;
        //	if ($servJSON->records[0]->u_organizational_group !== "UW-IT") { $classes[]="xxx";}
        $classes[] = $class;
    }
    if (!empty($JSON->records)) {
        $sn_data = array();
        foreach ($JSON->records as $record) {
            // if ($record->cmdb_ci == "") { continue; }
            if (!isset($sn_data[$record->cmdb_ci])) {
                $sn_data[$record->cmdb_ci] = array();
                unset($first);
            } else {
                $first = $sn_data[$record->cmdb_ci][1];
                //cannot assume order. load current first for ci
            }
            $create = $record->sys_created_on;
            if (!isset($first)) {
                $first = $create;
            }
            if ($create < $first) {
                $first = $create;
            }
            $sn_data[$record->cmdb_ci][] = $record;
            $sn_data[$record->cmdb_ci][] = $first;
        }
        ksort($sn_data, SORT_STRING | SORT_FLAG_CASE);
        //sort alphabetically by ci name
        echo "<h2 class='assistive-text' id='impact_headeing'>Impacted Services</h2>";
        # put the services into a single ordered list
        echo "<div class='row' aria-labelledby='impact_heading'>";
        $i = 0;
        foreach ($sn_data as $ci) {
            $update_time = new DateTime();
            $current_update_time = new DateTime();
            $count = 0;
            foreach ($ci as $incident) {
                //count incidents for ci
                if (!is_string($incident)) {
                    $current_update_time = DateTime::createFromFormat("m-d-Y H:i:s", $incident->sys_updated_on);
                    if ($count == 0 || $update_time < $current_update_time) {
                        $update_time = $current_update_time;
                    }
                    $count++;
                }
            }
            $class = $classes[$i];
            $service = array_search($ci, $sn_data);
            // handle the case of blank services and switches who's 'name' is a sequence of 5 or more numbers
            //if ( $service !== '' && !preg_match('/^\d{5,}$/', $service) ) {
            if ($service !== '') {
                //print_r( $ci);
                //		echo $ci[0]['cmdb_ci'];
                $time = end($ci);
                echo "<div class='servicecontent row'>";
                echo "<div class='servicewrap row'>";
                echo "<span class='glyphicon glyphicon-chevron-right switch' style='display:inline-block;float:left;'></span>";
                echo "<span class='service_name col-lg-5 col-md-5 col-sm-7 col-xs-7' style='font-weight:bold; display:inline-block;'>" . $service . " (" . $count . ")</span>";
                echo "<span class='service_class hidden-xs hidden-sm col-lg-2 col-md-2' style='display:inline-block; font-size:90%;'>{$class}</span>";
                echo "<span class='service_time col-lg-4 col-md-4 col-sm-4 col-xs-4' style='color:#aaa; font-size:95%; display:inline-block;'><span class='hidden-sm hidden-xs'>Reported at </span>{$time}<br><span class='hidden-sm hiiden-xs'>Updated at " . $update_time->format('m-d-Y H:i:s') . "</span></span>";
                echo "</div>";
                echo "<ul class='relatedincidents'>";
                echo "<li class='incident-head row'>";
                echo "<div class='col-lg-3 col-md-3 col-sm-3 col-xs-3'>Incident Number</div>";
                echo "<div class='col-lg-9 col-md-9 col-sm-9 col-xs-9'>Description</div>";
                echo "</li>";
                foreach ($ci as $incident) {
                    if (!is_string($incident)) {
                        // echo "<a href='/itconnect/incident/$incident->number'><li class='incident row'>";
                        echo "<li class='incident row'>";
                        echo "<div class='col-lg-3 col-md-3 col-sm-3 col-xs-3 '>" . $incident->number . "</div>";
                        echo "<div class='col-lg-4 col-md-4 col-sm-4 col-xs-4 inc_sdesc'>" . $incident->short_description . "</div>";
                        if ($count > 1) {
                            //if there is only one incident, don't show time twice.
                            echo "<div class='col-lg-4 col-md-4 col-sm-4 col-xs-4' style='color:#aaa; font-size:95%; display:inline-block;'><span class='hidden-sm hidden-xs'>Reported at</span> " . $incident->sys_created_on . "<br>Updated at " . $incident->sys_updated_on . "</div>";
                        }
                        echo "</li>";
                        //echo "</li></a>";
                    }
                }
                echo "</ul>";
                echo "</div>";
            }
            $i++;
        }
        echo "</div>";
    }
    echo "<p class='alert' style='margin-top: 2em;'>Experiencing IT problems not listed on this page? <a href=\"" . get_option('uwc_SN_URL') . "/uwc.do?sysparm_direct=true#/catalog_order/13234c686f377900328c8bec5d3ee444\">Submit an incident report</a> for any issues you are currently experiencing or call (206) 221-5000. </a></p>";
    die;
}
 echo "<h3 style='margin-top:2em;'>Description:</h3><div><pre>" . stripslashes($record->description) . " </pre></div>";
 if ($record->state == "Closed") {
     echo "<p class='alert alert-error'>This record has been closed. If you wish to revisit this issue, you can reference the issue number above in a new request to <a href='mailto:help@uw.edu'>help@uw.edu</a>.";
 }
 echo "<h3 style='margin-top:2em;'>Additional comments:</h3>";
 usort($comments, 'sortByCreatedOnDesc');
 //comments sorted chronologically descending
 echo "<ol style='margin-left:0;'>";
 $prevwatch = array();
 foreach ($comments as $comment) {
     $watcher = False;
     $comment_user = $comment->sys_created_by;
     //is this user the logged in user or do we know they're in the watch list already? if not get their SN sys_id
     if (!in_array($comment_user, $prevwatch)) {
         $user_url = '/sys_user_list.do?JSONv2&sysparm_query=user_name%3D' . $comment_user;
         $user_json = get_SN($user_url, $args);
         $comment_user_id = $user_json->records[0]->sys_id;
         //Are they a watcher?
         if (in_array($comment_user_id, $watch_list)) {
             $watcher = True;
             //We've seen them now
             array_push($prevwatch, $comment_user);
         }
     } else {
         if (in_array($comment_user, $prevwatch)) {
             $watcher = True;
         } else {
         }
     }
     echo "<li class='media'>";
     //Check who the commenter is, following roles win in order listed if a user is more than one