Exemple #1
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;
}
            echo '<font color="red">' . $done[2]['message'] . '</font>';
        }
    }
    ?>
<body onload="kill_me()"> 
<?php 
    echo '<form action="' . $action['deletestatement'] . '" method="post" autocomplete="on">
<table border="0">
        <tr>
                <td>Deleting statement #' . $statement_info['statement_id'] . '</td><td align="right"><font color="red"><b>' . $instance_info['notes'] . '</b></font></td>
        </tr>

</table>
<table>
        <tr>
                <td colspan="2"><hr color="navy" size="2"></hr></td>
        </tr>
        <tr>
                <td style="color: red" colspan="2"><br />Do you really want to delete the following statement?<br /><br /></td>';
    $displayInfo = array('Project:' => $project_info['project_name'], 'ID:' => $statement_info['resource_id'], 'Subject' => $statement_info['subject'], 'Verb' => $statement_info['verb'], 'Object' => $statement_info['object'], 'Value' => viewStatementValue($statement_info), 'Notes' => $statement_info['notes'], 'Created On:' => $statement_info['created_on'], 'Created By:' => find_user_loginID(array('account_id' => $statement_info['created_by'], 'db' => $db)), 'Modified By:' => find_user_loginID(array('account_id' => $statement_info['modified_by'], 'db' => $db)), 'Modified On:' => $statement_info['modified_on']);
    foreach ($displayInfo as $title => $something) {
        echo '<tr>';
        echo '<td>' . $title . '</td>';
        echo '<td>' . $something . '</td>';
        echo '</tr>';
    }
    echo '<tr><td><input type="submit" name="delete_statement" value="&nbsp;&nbsp;Delete&nbsp;&nbsp;"></td></tr>
</table>
</form>
</body>';
}