Example #1
0
function render_empty_form($F)
{
    $action = $GLOBALS['webaction'];
    extract($F);
    $rule_id = $rule_info['rule_id'];
    $stat = sprintf("\n%s\n", '<table width="100%">');
    $stat .= sprintf("%s\n", '<tr bgcolor="lightyellow"><td colspan="3">');
    $stat .= sprintf("%s\n", '[' . $rule_info['subject'] . ' | <a id="' . $rule_info['rule_id'] . '">' . printVerbStat($rule_info['verb']) . ' | <b>' . $rule_info['object'] . '</b> ] <font size=2 color=red>(R' . $rule_info['rule_id'] . ')</font><br />&nbsp;&nbsp;&nbsp;&nbsp;');
    $stat .= sprintf("%s\n", '<font size-=2 color=dodgerblue>' . ($rule_info['validation'] != '' ? 'Validation: ' . $rule_info['validation'] : '') . '</font>');
    $stat .= sprintf("%s\n", '</td></tr>');
    $stat .= sprintf("%s\n", '<tr><td width="33%"><b><font color="navy" size="-1">&nbsp;&nbsp;Value</font></b></td><td width="33%"><b><font color="navy" size="-1">Notes</font></b></td><td width="33%"><b><font color="navy" size="-1"><a href="' . S3DB_URI_BASE . '/statement/jumpuploader.php?rule_id=' . $rule_id . '&item_id=' . $instance_id . '" title="Please note that importing a file will take the place of the Value of the statement. You may add another statement to this item if you wish to keep both.">Multiple Files</a></font></b></td>');
    #$stat .= sprintf("%s\n", '<tr><td width="33%"><b><font color="navy" size="-1">&nbsp;&nbsp;Value</font></b></td><td width="33%"><b><font color="navy" size="-1">Notes</font></b></td><td width="33%"><b><font color="navy" size="-1"><a href="#" title="Please note that importing a file will take the place of the Value of the statement. You may add another statement to this item if you wish to keep both.">File (hover for instructions)</a></font></b></td>');
    $stat .= sprintf("%s\n", '<tr><td valign="top" width="33%">');
    if ($rule_info['add_data']) {
        if ($rule_info['object_id'] != '') {
            $select_name = 'input_' . $instance_id . '_' . $rule_id;
            $inputBox = get_rule_drop_down_menu(compact('select_name', 'rule_info', 'project_id', 'db', 'user_id'));
        } else {
            $inputBox = sprintf("%s\n", '<textarea style="background: lightyellow" name="input_' . $instance_id . '_' . $rule_id . '" cols="20"></textarea>');
            $peek = '';
        }
    } else {
        $inputBox = sprintf("%s\n", '<I><font color="red">User cannot add data to this rule</font></I>');
        $peek = '';
    }
    $stat .= $inputBox;
    $stat .= $peek . "</td>";
    $stat .= sprintf("%s\n", '<td valign="top"  width="33%"><textarea style="background: lightyellow" name="text_' . $instance_id . '_' . $rule_info['rule_id'] . '" rows="2" cols="20"></textarea></td>');
    $stat .= sprintf("%s\n", '<td valign="top"  width="33%"><input name="upload_input_' . $instance_id . '_' . $rule_id . '" type="file"><font style="font-size: 10"></font></td>');
    #$stat .= sprintf("%s\n", '<td valign="top"><input type="submit" name="insert_'.$resource_id.'_'.$rule_id.'" value="Insert">');
    $stat .= sprintf("\n%s\n", '<tr><td colspan="3"><hr size="1" align="center" color="blue"></hr></td></tr>');
    $stat .= sprintf("%s\n", '</table>');
    #$stat .=sprintf("%s\n", '</form>');
    $stats .= $stat;
    //echo " I am here";
    return $stats;
}
Example #2
0
function display_option($C)
{
    extract($C);
    #echo '<pre>';print_r($cells);
    $action = $GLOBALS['webaction'];
    $tablecells .= '';
    $tablecells .= '<form name = "importform" action = "' . $action['excelimport'] . '" method="POST">';
    $tablecells .= "<table width='100%'><tr bgcolor=lightyellow><td>3. Select fields to be updated</td></tr></table>";
    $tablecells .= "<TABLE border=1>";
    $tablecells .= "<TR>";
    #start the row where the rule are displayed
    #echo '<pre>';print_r($cells);exit;
    foreach ($cells['rules'] as $col => $rules) {
        if ($col == 0) {
            $tablecells .= '<TD><BR>UID<BR><br>';
            $tablecells .= '<input type="button" value="Check all" name="fieldcheck' . $col . '" onClick="this.value=check_rule(' . $col . ')" checked><BR></TD>';
        } elseif ($col == 1) {
            $tablecells .= '<TD>';
            $tablecells .= 'Notes';
            $tablecells .= '<BR><br><br><input type="button"  value="Check all" "fieldcheck' . $col . '" onClick="this.value=check_rule(' . $col . ')" checked><BR>';
            $tablecells .= '</TD>';
        } elseif ($col >= 2) {
            if (is_array($rules['rule_info'])) {
                $tablecells .= '<TD>' . $rules['rule_info']['verb'] . '<BR><font color=blue>' . $rules['rule_info']['object'] . '<BR>(rule id ' . $rules['rule_info']['rule_id'] . ')</font><BR><input type="button"  value="Check all" name="fieldcheck' . $col . '" onClick="this.value=check_rule(' . $col . ')"  checked></TD>';
            } else {
                $tablecells .= '<TD><BR>' . $rules['verb'] . '<BR><font color=red>' . $rules['object'] . '<BR>(rule id NOT FOUND)</font>';
                $tablecells .= '<br>';
                $tablecells .= 'create rule?';
                $tablecells .= '<input type="checkbox" name="newrule_0_' . $col . '" checked>';
                $tablecells .= '<input type="button"  value="Check all" name="fieldcheck' . $col . '" onClick="this.value=check_rule(' . $col . ')" checked></TD>';
            }
        }
    }
    $tablecells .= "</TR>";
    foreach ($cells['data'] as $row => $row_data) {
        $tablecells .= '<TR>';
        for ($col = 0; $col < count($cells['rules']); $col++) {
            if ($col == 0) {
                $tablecells .= '<TD>';
                if ($row_data['UID'] == '') {
                    $tablecells .= '(no UID)';
                    $tablecells .= '<input type="checkbox" name="newinstance_' . $row . '" id="confirm_me' . $col . '[]" checked>';
                } elseif ($row_data['UID'] != '' && !is_array($row_data['instance_info'])) {
                    #so, the instance was not found?
                    $tablecells .= '<font color=red>';
                    $tablecells .= '(UID not found)';
                    $tablecells .= '</font>';
                    $tablecells .= '<br>new?';
                    $tablecells .= '<input type="checkbox" name="newinstance_' . $row . '" id="confirm_me' . $col . '[]" checked>';
                } else {
                    $tablecells .= instanceButton($row_data['instance_info']);
                    $tablecells .= '<input type="checkbox" name="confirminstance_' . $row . '" id="confirm_me' . $col . '[]" checked>';
                }
                $tablecells .= '</TD>';
            } elseif ($col == 1) {
                $tablecells .= '<TD>';
                if (!is_array($row_data['instance_info']) && $row_data[1] == '') {
                    #no a ,no b
                    $tablecells .= '(notes empty)';
                } elseif ($row_data[1] != '' && !is_array($row_data['instance_info'])) {
                    #a but no b
                    $tablecells .= $row_data[1];
                    $tablecells .= '<input type="checkbox" name="confirmnotes_' . $row . '" id="confirm_me' . $col . '[]" checked>';
                } elseif ($row_data[1] == '' && is_array($row_data['instance_info']) && $row_data['instance_info']['notes'] != '') {
                    #b but no a
                    $tablecells .= 'old:' . $row_data['instance_info']['notes'] . '<br>';
                    $tablecells .= 'new: (empty)<br>';
                    if ($row_data['instance_info']['add_data']) {
                        $tablecells .= '<font color=red>';
                        $tablecells .= 'delete?';
                        $tablecells .= '</font>';
                        $tablecells .= '<input type="checkbox" name="confirmnotes_' . $row . '" value="editnotes_' . $row_data['instance_info']['resource_id'] . '" id="confirm_me' . $col . '[]" checked>';
                    } else {
                        #uh ho, you're not allowed!
                        $tablecells .= '<font color=red>';
                        $tablecells .= 'User is not allowed to change instance_id ' . $row_data['instance_info']['resource_id'];
                        $tablecells .= '</font>';
                    }
                } elseif ($row_data[1] != '' && is_array($row_data['instance_info']) && $row_data['instance_info']['notes'] == $row_data[1]) {
                    #a==b
                    #this is an intance where notes were NOT modified
                    $tablecells .= $row_data[1];
                    $tablecells .= '<br>';
                    $tablecells .= '<font color=navy>';
                    $tablecells .= '(no change)';
                    $tablecells .= '</font>';
                } elseif ($row_data[1] != '' && is_array($row_data['instance_info']) && $row_data[1] != $row_data['instance_info']['notes']) {
                    #a!=b this is an intance where notes were modified
                    $tablecells .= 'old:' . $row_data['instance_info']['notes'] . '<br>';
                    if ($row_data['instance_info']['add_data']) {
                        $tablecells .= '<font color=DarkGreen>';
                        $tablecells .= 'new:' . $row_data[1] . '';
                        $tablecells .= '</font>';
                        $tablecells .= '<br>edit?';
                        $tablecells .= '<input type="checkbox" name="confirmnotes_' . $row . '" value="editnotes_' . $row_data['instance_info']['resource_id'] . '" id="confirm_me' . $col . '[]" checked>';
                    } else {
                        $tablecells .= '<font color=red>';
                        $tablecells .= 'User is not allowed to change instance_id ' . $row_data['instance_info']['resource_id'];
                        $tablecells .= '</font>';
                    }
                }
                $tablecells .= '</TD>';
            } elseif ($col >= 2) {
                $tablecells .= '<TD>';
                $statement_info = $row_data[$col]['statement_info'];
                #if ($rules['rule_info']['rule_id']=='') {#no rule
                #$tablecells .='(Data will NOT be imported)';
                #}
                #else
                if ($statement_info['value'] == '' && $row_data[$col]['newvalue'] == '') {
                    $tablecells .= '';
                } elseif ($row_data[$col]['newvalue'] != '' && empty($statement_info['value'])) {
                    #a but not b this means nothing was there, no checking required except for rule
                    if (!is_array($cells['rules'][$col]['rule_info'])) {
                        $tablecells .= $row_data[$col]['newvalue'];
                    } elseif ($cells['rules'][$col]['rule_info']['object_id'] == '') {
                        $tablecells .= $row_data[$col]['newvalue'];
                    } else {
                        $IN_instance_info = s3info('instance', $row_data[$col]['newvalue'], $db);
                        if (!is_array($IN_instance_info)) {
                            $tablecells .= '<font color=red>';
                            $tablecells .= '(UID ' . $row_data[$col]['newvalue'] . ' not found)';
                            $tablecells .= '<br>';
                            $tablecells .= 'Please insert a valid resource';
                            $tablecells .= '</font>';
                            $tablecells .= get_rule_drop_down_menu(array('select_name' => 'selectstatement_' . $row . '_' . $col, 'rule_info' => $cells['rules'][$col]['rule_info'], 'db' => $db, 'user_id' => $user_id, 'project_id' => $project_id, 'instance_id' => $row_data['instance_info']['resource_id']));
                        } else {
                            #object is a resource and instance was found
                            $tablecells .= instanceButton($IN_instance_info);
                        }
                    }
                    $tablecells .= '<br>';
                    $tablecells .= '<input type="checkbox" name="insertstatement_' . $row . '_' . $col . '" value="insertstatement_' . $row_data['instance_info']['resource_id'] . '_' . $rule_id . '" id="confirm_me' . $col . '[]" checked>';
                } elseif ($row_data[$col]['newvalue'] == '' && is_array($statement_info) && $statement_info['value'] != '') {
                    #b but not a #here is something being deleted
                    if ($statement_info['change']) {
                        if ($statement_info['file_name'] != '') {
                            $tablecells .= '<font color=red>';
                            $tablecells .= '(statement contains a file, please change it in the interface)<br /><a href=# onClick="window.open(\'' . $action['instance'] . '&instance_id=' . $statement_info['resource_id'] . '\')">Edit</a>';
                            $tablecells .= '</font>';
                        } else {
                            if ($cells['rules'][$col]['rule_info']['object_id'] == '') {
                                $tablecells .= 'old: ' . $statement_info['value'];
                            } else {
                                $OUT_instance_info = get_info('instance', $statement_info['value'], $db);
                                $tablecells .= 'old: ' . instanceButton($OUT_instance_info);
                            }
                            $tablecells .= '<br>';
                            $tablecells .= '<font color=red>';
                            $tablecells .= 'new: (empty)<br>';
                            $tablecells .= 'delete?';
                            $tablecells .= '</font>';
                            $tablecells .= '<input type="checkbox" name="deletestatement_' . $row . '_' . $col . '" value="deletestatement_' . $row_data['instance_info']['resource_id'] . '_' . $rule_id . '" id="confirm_me' . $col . '[]">';
                        }
                    } else {
                        $tablecells .= 'old: ' . $statement_info['value'];
                        $tablecells .= '<font color=red>';
                        $tablecells .= 'User does not have permission to delete statement_id ' . $statement_info['statement_id'] . '!!';
                        $tablecells .= '</font>';
                    }
                } elseif ($row_data[$col]['newvalue'] != '' && is_array($statement_info) && $statement_info['value'] == $row_data[$col]['newvalue']) {
                    #a==b nothing to change
                    if ($cells['rules'][$col]['rule_info']['object_id'] == '') {
                        $tablecells .= $statement_info['value'];
                    } else {
                        $OUT_instance_info = get_info('instance', $statement_info['value'], $db);
                        $tablecells .= instanceButton($OUT_instance_info);
                    }
                    $tablecells .= '<font color=navy>';
                    $tablecells .= '<br>';
                    $tablecells .= '(no change)';
                    $tablecells .= '</font>';
                } elseif ($row_data[$col]['newvalue'] != '' && is_array($statement_info) && $statement_info['value'] != '' && $statement_info['value'] != $row_data[$col]['newvalue']) {
                    #a!=b
                    if ($statement_info['change']) {
                        if ($statement_info['file_name'] != '') {
                            $tablecells .= '<font color=red>';
                            $tablecells .= '(statement contains a file, please change it in the interface)<br /><a href=# onClick="window.open(\'' . $action['instance'] . '&instance_id=' . $statement_info['resource_id'] . '\')">Edit</a>';
                            $tablecells .= '</font>';
                        } else {
                            if ($cells['rules'][$col]['rule_info']['object_id'] == '') {
                                $tablecells .= 'old: ' . $statement_info['value'];
                                $tablecells .= '<br>';
                                $tablecells .= 'new: ' . $row_data[$col]['newvalue'];
                            } else {
                                $OLD_instance_info = URIinfo('I' . $statement_info['value'], $user_id, $key, $db);
                                $NEW_instance_info = URIinfo('I' . $row_data[$col]['newvalue'], $user_id, $key, $db);
                                $tablecells .= 'old: ' . instanceButton($OLD_instance_info);
                                $tablecells .= '<br>';
                                if (!is_array($NEW_instance_info)) {
                                    $tablecells .= '<font color=red>';
                                    $tablecells .= '(UID ' . $row_data[$col]['newvalue'] . ' not found)';
                                    $tablecells .= '<br>';
                                    $tablecells .= 'Please insert a valid resource';
                                    $tablecells .= '</font>';
                                    $tablecells .= get_rule_drop_down_menu(array('select_name' => 'selectstatement_' . $row . '_' . $col, 'rule_info' => $cells['rules'][$col]['rule_info'], 'db' => $db, 'user_id' => $user_id, 'project_id' => $project_id, 'instance_id' => $row_data['instance_info']['resource_id']));
                                } else {
                                    $NEW_instance_info = URIinfo('I' . $row_data[$col]['newvalue'], $user_id, $key, $db);
                                    $tablecells .= 'new: ' . instanceButton($NEW_instance_info);
                                }
                            }
                            $tablecells .= '<br>';
                            $tablecells .= '<font color=DarkGreen>';
                            $tablecells .= 'edit?';
                            $tablecells .= '</font>';
                            $tablecells .= '<input type="checkbox" name="editstatement_' . $row . '_' . $col . '" value="editstatement_' . $row_data['instance_info']['resource_id'] . '_' . $rule_id . '" id="confirm_me' . $col . '[]" checked>';
                        }
                    } else {
                        $tablecells .= 'old: ' . $statement_info['value'];
                        $tablecells .= '<font color=red>';
                        $tablecells .= 'User does not have permission to delete statement_id ' . $statement_info['statement_id'] . '!!';
                        $tablecells .= '</font>';
                    }
                }
                $tablecells .= '</TD>';
            }
        }
        $tablecells .= '</TR>';
    }
    $tablecells .= '<input type="submit" name="InsertinDB" value="Import ' . $resource_info['entity'] . '"><BR>';
    $tablecells .= '</table>';
    return $tablecells;
}