示例#1
0
文件: count.php 项目: ben-garside/XCP
<?php

require "../php/init.php";
$db = DB::getInstance();
$act = Input::get('act');
$outArray = array();
$streams = Activity::getStreams();
foreach ($streams as $stream) {
    $sql = "SELECT stream_id, COUNT(*) TOTAL,\n\t\t\t\t\tsum(case when allocatedTo IS NOT NULL  then 1 else 0 end) as ASSIGNED,\n\t\t\t\t\tsum(case when allocatedTo IS NULL then 1 else 0 end) as UNASSIGNED\n\t\t\tFROM mainData\n\t\t\tOUTER APPLY (SELECT TOP 1 * FROM ACT_AUDIT WHERE XCPID = mainData.XCP_ID order by id desc) AUDIT\n\t\t\tWHERE stream_id = " . $stream->id . "\n\t\t\tGROUP BY stream_id";
    $data = $db->query($sql);
    $result = $data->first();
    if (!($assigned = $result->ASSIGNED)) {
        $assigned = 0;
    }
    if (!($unassigned = $result->UNASSIGNED)) {
        $unassigned = 0;
    }
    if (!($total = $result->TOTAL)) {
        $total = 0;
    }
    $outArray[] = array("Pipeline" => $stream->id, "Status" => "ASSIGNED", "Count" => $assigned);
    $outArray[] = array("Pipeline" => $stream->id, "Status" => "TOTAL", "Count" => $total);
    $outArray[] = array("Pipeline" => $stream->id, "Status" => "UNASSIGNED", "Count" => $unassigned);
}
header("Content-type: application/json");
print json_encode($outArray);
示例#2
0
    <label class="sr-only" for="select_feed">Select feed </label>
    <select id="select_feed" name="feed" class="form-control">
      <option value="0">All feeds</option>
      <?php 
foreach (Activity::getFeeds() as $feed) {
    echo '<option value="' . $feed->feed_id . '">' . $feed->feed_name . '</option>';
}
?>
    </select>
  </div>
  <div class="form-group">
    <label class="sr-only" for="select_Pipeline">Select Pipeline</label>
    <select id="select_Pipeline" name="Pipeline" class="form-control">
      <option value="0">All pipelines</option>
      <?php 
foreach (Activity::getStreams() as $stream) {
    echo '<option value="' . $stream->id . '">' . $stream->name . '</option>';
}
?>
    </select>
  </div>
  <input type="hidden" value="" id="select_act" name="act"/>
  <?php 
if ($user->inRole(1)) {
    ?>
        <div class="form-group">
          <label class="sr-only" for="select_Pipeline">Select Pipeline</label>
          <select id="uid" name="uid" class="form-control">
            <option value="<?php 
    echo $user->data()->id;
    ?>