示例#1
0
     $s3ql['select'] = '*';
     $s3ql['from'] = 'statements';
     $s3ql['where']['instance_id'] = $instances[$k]['resource_id'];
     $all_values = S3QLaction($s3ql);
     $_SESSION['queryresult'][$k]['stats'] = $all_values;
 } else {
     $all_values = $instances[$k]['stats'];
 }
 #echo '<pre>';print_r($s3ql);
 #echo '<pre>';print_r($all_values);exit;
 #reset rule keys
 $statSum = $statSum + count($all_values);
 #echo '<pre>';print_r($all_values);
 $row = $kk + 3 + $addtoNextRow;
 #resources with statements, put an lines for more than 1 stat per rule
 $n = get_max_num_values($all_values, $rules) == 0 ? 1 : get_max_num_values($all_values, $rules);
 for ($m = 0; $m < $n; $m++) {
     ##Resource_id and notes in the first and seecond col
     $subrow = $row + $m;
     $worksheet->write($subrow, 0, $instances[$k]['resource_id']);
     $worksheet->write($subrow, 1, $instances[$k]['notes']);
     if (is_array($rules)) {
         foreach ($rules as $j => $value) {
             $rule_id = $rules[$j]['rule_id'];
             $values = get_value_by_rule($all_values, $rule_id);
             #echo $rule_id;
             #echo '<pre>';print_r($values);
             #show only the filename and not the values
             if ($values[$m]['file_name'] != '') {
                 $worksheet->write($subrow, $j + 2, $values[$m]['file_name']);
             } elseif (ereg('<a href=(.*)>(.*)<\\/a>', $values[$m]['value'], $href)) {
示例#2
0
function render_datamatrix_values($vals)
{
    $action = $GLOBALS['webaction'];
    extract($vals);
    $color = $_REQUEST['color'];
    $format = $_REQUEST['format'];
    $parser = get_parser_characters($format);
    $rows = '';
    $items = $instances;
    //		if($_REQUEST['num_per_page']!='' && $_REQUEST['current_page']!='')
    //			{
    //			$start = (($_REQUEST['current_page']-1)*$_REQUEST['num_per_page']);
    //			$end=($_REQUEST['num_per_page']*$_REQUEST['current_page']);
    //			}
    //			else {
    //				$start = 0;
    //				$end= count($items);
    //		}
    #if(is_array($matched_resource))
    for ($i = $start; $i < $end; $i++) {
        $item_id = $items[$i]['item_id'];
        if (!is_array($items[$i]['stats'])) {
            $row = '';
            $s3ql = compact('db', 'user_id');
            $s3ql['select'] = '*';
            $s3ql['from'] = 'statements';
            $s3ql['where']['item_id'] = $item_id;
            $all_values = S3QLaction($s3ql);
        } else {
            $all_values = $items[$i]['stats'];
        }
        #echo '<pre>';print_r($all_values);exit;
        if (is_array($all_values) && !empty($all_values)) {
            #replace values with filelinks and find the notes for the buttons
            $all_values = include_button_notes($all_values, $project_id, $db);
            $all_values = Values2Links($all_values);
        }
        if (count($all_values) == '0') {
            if ($color == 'on') {
                if ($total % 2 == 0) {
                    $row = sprintf("%s\n", '		<tr bgcolor="AliceBlue">');
                } else {
                    $row = sprintf("%s\n", $parser['tr']);
                }
                #$all_values = include_button_notes($all_values, $project_id, $db);
                #In case color is on, it means we are trying to achieve one of the interactive, user-friendly interfaces. Therefore, resource should come in the format of a button. Need to be dealt with care in case
                $resource_id_button = '<input type="button" size="10" value="' . str_pad($item_id, 6, '0', STR_PAD_LEFT) . '" onClick="window.open(\'' . $action['item'] . '&item_id=' . $item_id . '\', \'_blank\', \'width=700, height=600, location=no, titlebar=no, scrollbars=yes, resizable=yes\')">';
            } else {
                $resource_id_button = $item_id;
            }
            $subrow = '';
            $subrow .= sprintf("%s", $parser['td'] . $resource_id_button . $parser['end_td']);
            $subrow .= sprintf("%s", $parser['td'] . $items[$i]['notes'] . $parser['end_td']);
            #Moving on to the data on the rules, since there are no values on this row, print only opening and ending the cell
            if (is_array($rules)) {
                foreach ($rules as $j => $value) {
                    $subrow .= sprintf("%s", $parser['td'] . $parser['end_td']);
                }
            }
            $subrow .= sprintf("%s", $parser['end_tr']);
            $row .= $subrow;
            $total += 1;
        } else {
            $n = get_max_num_values($all_values, $rules) == 0 ? 1 : get_max_num_values($all_values, $rules);
            #$n will determine the number of lines for this item
            $total = 0;
            $row = '';
            for ($m = 0; $m < $n; $m++) {
                //$row ='';
                if ($_REQUEST['color'] == 'on') {
                    #if($total%2==0)
                    #$row .=sprintf("%s\n", '<tr bgcolor="AliceBlue">');}
                    #else
                    #$row .=sprintf("%s\n", $parser['tr']);
                    $resource_id_button = '<input type="button" size="10" value="' . str_pad($item_id, 6, '0', STR_PAD_LEFT) . '" onClick="window.open(\'' . $action['item'] . '&item_id=' . $item_id . '\', \'_blank\', \'width=700, height=600, location=no, titlebar=no, scrollbars=yes, resizable=yes\')">';
                } else {
                    $resource_id_button = $item_id;
                }
                $row .= sprintf("%s", $parser['tr']);
                $subrow = '';
                $subrow .= sprintf("%s", $parser['td'] . $resource_id_button . $parser['end_td']);
                $subrow .= sprintf("%s", $parser['td'] . $items[$i]['notes'] . $parser['end_td']);
                #if($item_id=='3783'){ echo $row ;  exit;}
                //print_r($rules);
                if (is_array($rules)) {
                    foreach ($rules as $j => $value) {
                        $rule_id = $rules[$j]['rule_id'];
                        $values = get_value_by_rule($all_values, $rule_id);
                        if ($format == 'html' && $color == 'on') {
                            $value = viewStatementValue($values[$m]);
                        } else {
                            $value = $values[$m]['value'];
                        }
                        if ($value != '') {
                            $subrow .= sprintf("%s", $parser['td'] . $value . $parser['end_td']);
                        } else {
                            $subrow .= sprintf("%s", $parser['td'] . $parser['end_td']);
                        }
                    }
                }
                $subrow .= sprintf($parser['end_tr']);
                $row .= $subrow;
            }
            $rows .= $row;
        }
    }
    $rows .= sprintf($parser['end_table']);
    return $rows;
}