Exemple #1
0
function create_statement($table_name, array $exclude)
{
    /* $exclude contains the columns we do not want */
    $column_names = get_column_names($table_name);
    $statement = "";
    foreach ($column_names as $name) {
        if (!in_array($name, $exclude)) {
            if ($statement == "") {
                $statement = $name;
            } else {
                $statement .= "," . $name;
            }
        }
    }
    return $statement;
}
function session_edit_form($session_id, $athlete_id, $error_message)
{
    # Put columns we never want to show in this array:
    $do_not_show = array("athlete_id", "session_id", "parent_session");
    $columns = get_column_names();
    # Get an array of fields user does want to display
    $display_details = array();
    $query = "SELECT detail from athlete_log_preferences\n        where athlete_id={$athlete_id} ";
    #       ORDER BY display_sequence";
    $result = do_sql($query) or die('Query failed: ' . pg_last_error());
    // pg_fetch_array returns the next whole row as an array at each iteration
    while ($row = pg_fetch_array($result, null, PGSQL_ASSOC)) {
        foreach ($row as $prev_detail) {
            array_push($display_details, $prev_detail);
        }
    }
    echo "{$error_message} \n";
    # Start Form and Table
    echo "<DIV id=mainlogentry > <a name=log_entry_form></a>";
    echo "<FORM action=update_log_entry.php method=post >\n";
    echo "<input type=hidden name='session_id' value={$session_id}>\n";
    echo "\n\n<TABLE class=mainlogentry ><TR><TD>\n\n";
    // Get Current row data
    $query = "SELECT * from log\n        where session_id={$session_id} ";
    $result = do_sql($query) or die('Query failed: ' . pg_last_error());
    // pg_fetch_array returns the next whole row as an array at each iteration
    // there really should only be 1 row returned here.
    // Check for date fields because we need to convert them
    $date_fields = array();
    $num = pg_num_fields($result);
    for ($fieldnum = 0; $fieldnum < $num; $fieldnum++) {
        if (pg_field_type($result, $fieldnum) == 'date') {
            // put names of all date fields into $date_fields
            $fieldname = pg_field_name($result, $fieldnum);
            array_push($date_fields, $fieldname);
        }
    }
    // Now stick the info for the row the user wants to edit into an array
    $session_details = pg_fetch_array($result, null, PGSQL_ASSOC);
    // Check for date fields and convert them
    // Get the fields names
    foreach (array_keys($session_details) as $field_name) {
        // and see if they are in the date_fields array
        if (in_array($field_name, $date_fields)) {
            // If they are then convert the date from pg format to d/m/y
            $session_details[$field_name] = convert_date_from_pg($session_details[$field_name]);
        }
    }
    // Dates are converted //
    // Display Entry fields
    // Save text/notes fields (ie data_type text or var > 50 ) in a variable to
    // display last
    $notes_fields = "";
    echo "<TR>\n";
    $maxnumcols = 6;
    $colcount = $maxnumcols;
    foreach ($display_details as $colname) {
        if (!in_array($colname, $do_not_show) && in_array($colname, $display_details)) {
            if ($colcount-- == 0) {
                echo "\n</TR>\n";
                $colcount = $maxnumcols - 1;
            }
            $colinfo = get_column_info($colname);
            $input_type = "text";
            $value = $session_details[$colname];
            if (preg_match("/^var/", $colinfo['data_type'])) {
                // Get the var length
                $typearray = explode(" ", $colinfo['data_type']);
                $varlen = $typearray[1];
            }
            if (preg_match("/^select/", $colinfo['data_type'])) {
                // We have a select list type.  There should be a corresponding table
                // which lists the select info
                echo " <td align=center ><font size=1 > \n";
                echo $colinfo['log_col_long_name'] . " <BR>\n";
                generate_select_form($colname, $colinfo['data_type'], $value);
            } elseif (preg_match("/^pref/", $colinfo['data_type'])) {
                // We have a prefer select list type.  There should be a corresponding table
                // which lists the prefered select info
                echo " <td align=center ><font size=1 > \n";
                echo $colinfo['log_col_long_name'] . " <BR>\n";
                generate_prefer_select_form($colname, $colinfo['data_type'], $value, $athlete_id);
            } elseif ($colinfo['data_type'] == "text" || $varlen >= 30) {
                // Set maximum field size to 80
                if ($varlen <= 80) {
                    $size = $varlen;
                } else {
                    $size = 80;
                }
                $notes_fields = "{$notes_fields} <TR><TD> " . $colinfo['log_col_long_name'] . "</TD> <TD colspan=20 ><INPUT type=text name ={$colname} value='{$value}' size={$size} > </TD></TR>\n";
            } else {
                echo " <td align=center ><font size=1 > \n";
                echo $colinfo['log_col_long_name'] . " <BR>\n";
                echo "<INPUT type={$input_type} name={$colname} value='{$value}' size=10>\n";
            }
            echo "</font> </td>\n";
        }
    }
    echo "</TR>\n";
    echo "{$notes_fields}\n";
    echo "</TABLE>";
    echo "<input type=submit value='Submit entries'>";
    echo "</FORM>";
    echo "</DIV>";
    ## END of FUNCTION
}
function insert_results_indb($insert_values, $import)
{
    global $pdo;
    $fields = get_column_names();
    foreach ($fields as $field) {
        $item_f = $fields[1];
        $itemname_f = $fields[2];
        $upc_f = $fields[3];
        $mfgname_f = $fields[4];
        $mfgitemnumber_f = $fields[5];
        $price_f = $fields[6];
        $qty_f = $fields[7];
        $stn_skumatch_f = $fields[8];
        $stn_itemname_f = $fields[9];
        $stn_mfgname_f = $fields[10];
        $matchup_method_f = $fields[11];
        $grade_f = $fields[12];
        $plus_1_f = $fields[13];
        $import_status_f = $fields[14];
        $dup_sfield_f = $fields[15];
    }
    if ($import == 'Y' || $import == 'AI') {
        $query = "INSERT INTO \r\n\t\t\t\t\tstn_matchup_results( \r\n\t\t\t\t\t\t{$item_f},\r\n\t\t\t\t\t\t{$itemname_f},\r\n\t\t\t\t\t\t{$upc_f},\r\n\t\t\t\t\t\t{$mfgname_f},\r\n\t\t\t\t\t\t{$mfgitemnumber_f},\r\n\t\t\t\t\t\t{$price_f},\r\n\t\t\t\t\t\t{$qty_f},\r\n\t\t\t\t\t\t{$stn_skumatch_f},\r\n\t\t\t\t\t\t{$stn_itemname_f},\r\n\t\t\t\t\t\t{$stn_mfgname_f},\r\n\t\t\t\t\t\t{$matchup_method_f},\r\n\t\t\t\t\t\t{$grade_f},\r\n\t\t\t\t\t\t{$plus_1_f},\r\n\t\t\t\t\t\t{$import_status_f},\r\n\t\t\t\t\t\t{$dup_sfield_f} \r\n\t\t\t\t) VALUES( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )";
        $insert_results = $pdo->prepare($query);
        $insert_results->execute($insert_values);
    } else {
        $query = "INSERT INTO\r\n\t\t\t\t\tstn_matchup_results(\r\n\t\t\t\t\t\t{$item_f},\r\n\t\t\t\t\t\t{$itemname_f},\r\n\t\t\t\t\t\t{$upc_f},\r\n\t\t\t\t\t\t{$mfgname_f},\r\n\t\t\t\t\t\t{$mfgitemnumber_f},\r\n\t\t\t\t\t\t{$price_f},\r\n\t\t\t\t\t\t{$qty_f},\r\n\t\t\t\t\t\t{$stn_mfgname_f},\r\n\t\t\t\t\t\t{$matchup_method_f},\r\n\t\t\t\t\t\t{$grade_f},\r\n\t\t\t\t\t\t{$plus_1_f},\r\n\t\t\t\t\t\t{$import_status_f},\r\n\t\t\t\t\t\t{$dup_sfield_f}\r\n\t\t\t\t\t) VALUES( ?,?,?,?,?,?,?,?,?,?,?,?,? )\r\n\t\t\t\t ";
        $insert_results = $pdo->prepare($query);
        $insert_results->execute($insert_values);
    }
}
Exemple #4
0
function display_column_headers($details_to_view)
{
    // Only used for subsession (split) tables
    $headers = get_column_names();
    $col_info = get_col_info($details_to_view);
    $col_widths = $col_info['col_widths'];
    $col_shnames = $col_info['col_shnames'];
    // Set column widths for table column Header
    echo "<TABLE class=subtable cellspacing=0 >\n";
    echo "<COL WIDTH=0 > <COL WIDTH=0>\n";
    foreach ($details_to_view as $detail) {
        $width = $col_widths[$detail];
        echo "<COL WIDTH={$width} >\n";
    }
    echo "<COL WIDTH=50>\n";
    echo <<<ENDHTML
  <tr>
  <td class=colheader >&nbsp;</td>
  <td class=colheader >&nbsp;</td>
ENDHTML;
    foreach ($details_to_view as $detail) {
        $width = $col_widths[$detail];
        $name = $col_shnames[$detail];
        echo " <td class=colheader >{$name}</td>\n  ";
    }
    echo "<td class=colheader >&nbsp;</td>\n";
    echo "</tr>";
}
Exemple #5
0
function view_all_year_end_poll_for($poll)
{
    $column_names = get_column_names($poll);
    echo "<table class=\"table table-striped table-bordered-horizontal table-condensed table-center\">\n<thead>";
    for ($i = 0; $i <= count($column_names); $i++) {
        if ($column_names[$i] != 'id') {
            echo "<th>" . ucwords(format_poll_name($column_names[$i])) . "</th>";
        }
    }
    echo "</thead>\n";
    $query = "SELECT * FROM year_end_" . $poll . " ORDER BY votes DESC, " . $column_names[1] . " ASC";
    $result = mysql_query($query);
    for ($i = 1; $i <= mysql_num_rows($result); $i++) {
        $info = mysql_fetch_assoc($result);
        echo "<tr>";
        for ($j = 1; $j <= count($column_names); $j++) {
            echo "<td>" . $info[$column_names[$j]] . "</td>";
        }
        echo "</tr>";
    }
    echo "</table";
}
<?php

$poll_values = get_values($current_poll);
$category = ucwords(str_replace("_", " ", $current_poll));
$column_names = get_column_names($current_poll);
echo "<h2 class=\"center top-spacer_20\">" . format_poll_header($current_poll, $category) . "</h2>\n\n    <form action=\"yearendpoll.php\" method=\"post\" name=\"year_end_" . $current_poll . "\" class=\"form-default\">\n    <fieldset>\n<div class=\"control-group\">\n<div class=\"controls\">\n";
for ($i = 1; $i <= mysql_num_rows($poll_values); $i++) {
    $info = mysql_fetch_assoc($poll_values);
    echo "<label for=\"" . $info['id'] . "\" class=\"half\"><input type=\"checkbox\" name=\"year_end_votes[]\" id=\"" . $info['id'] . "\" value=\"" . $info['id'] . "\">";
    for ($c = 1; $c <= count($column_names) - 2; $c++) {
        echo "<span>" . $info[$column_names[$c]];
        if ($column_names[$c + 1] != 'votes') {
            echo " - ";
        }
    }
    echo "\n</span>\n</label>\n";
}
echo "</div>\n<div class=\"control-group top-spacer_20\">\n\n    <div class=\"controls\">\n\n    <input type=\"checkbox\" id=\"song_write_in\"> <input type=\"text\" disabled=\"disabled\" class=\"input-xl\" id=\"write_in_value\" name=\"write_in_value\">\n\n    <div class=\"form-other\">Other (please specify)</div>\n</div>\n</div>\n\n    </div>\n<div class=\"form-actions\">\n<button class=\"btn-info disabled\" type=\"submit\" disabled=\"disabled\" id=\"vote\">Pick " . max_picks_for($current_poll) . " more!</button>\n\n    <input type=\"hidden\" name=\"poll\" value=" . $current_poll . ">\n</div>\n\n    </form>\n</div>\n</fieldset>";