示例#1
0
function create_event_edit_form()
{
    echo '<div class="calendar_edit_event_form">';
    if (isset($_POST[event_calendar_cancel_submit])) {
        unset($_GET[id]);
        unset($_POST);
    }
    //the form handling
    if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST[event_calendar_edit_submit])) {
        //debug
        $temp = $_POST[description];
        if ($_POST[delete_event] == 'y') {
            echo '<div class="event_calendar_notification"';
            if (is_string($error = validate_post_data($_POST, 'delete'))) {
                //validate data
                echo '>' . $error;
            } else {
                if (is_string($error = post_event_data($_POST, 'delete'))) {
                    //post data
                    echo '>' . $error;
                } else {
                    echo ' id="event_calendar_notification_data_correct">Event Deleted';
                }
                unset($_GET[id]);
            }
            echo '</div>';
        } else {
            //concatenate the date together
            $_POST[datetime_start] = $_POST[datetime_start_year] . '-' . $_POST[datetime_start_month] . '-' . $_POST[datetime_start_day] . ' ' . $_POST[datetime_start_hour] . ':' . $_POST[datetime_start_mins];
            $_POST[datetime_end] = $_POST[datetime_end_year] . '-' . $_POST[datetime_end_month] . '-' . $_POST[datetime_end_day] . ' ' . $_POST[datetime_end_hour] . ':' . $_POST[datetime_end_mins];
            echo '<div class="event_calendar_notification"';
            if (is_string($error = validate_post_data($_POST, 'update'))) {
                //validate data
                echo '>' . $error;
            } else {
                if (is_string($error = post_event_data($_POST, 'update'))) {
                    //post data
                    echo '>' . $error;
                } else {
                    echo ' id="event_calendar_notification_data_correct">Data Posted Correctly';
                }
            }
            echo '</div>';
        }
    }
    if (isset($_GET[id]) && is_numeric($_GET[id])) {
        //get event data.
        get_event_info_by_id($_GET[id], $_POST);
        //start time
        $start = explode(" ", $_POST[datetime_start]);
        $start_date = explode("-", $start[0]);
        $start_time = explode(":", $start[1]);
        $_POST[datetime_start_year] = $start_date[0];
        $_POST[datetime_start_month] = $start_date[1];
        $_POST[datetime_start_day] = $start_date[2];
        $_POST[datetime_start_hour] = $start_time[0];
        $_POST[datetime_start_mins] = $start_time[1];
        //end time
        $end = explode(" ", $_POST[datetime_end]);
        $end_date = explode("-", $end[0]);
        $end_time = explode(":", $end[1]);
        $_POST[datetime_end_year] = $end_date[0];
        $_POST[datetime_end_month] = $end_date[1];
        $_POST[datetime_end_day] = $end_date[2];
        $_POST[datetime_end_hour] = $end_time[0];
        $_POST[datetime_end_mins] = $end_time[1];
        //actual form
        echo '<form action="' . htmlspecialchars($_SERVER["PHP_SELF"]) . '?' . generate_get_string() . '" method="post" ><table class="calendar_layout_table">';
        echo '<input type="hidden" name="id" value="' . $_GET[id] . '">';
        //Event title
        echo '<tr><td class="calendar_layout_table">Event Title:</td><td class="calendar_layout_table"><input type="text" name="event_title" value="' . $_POST[event_title] . '"></td></tr>';
        //Event Class
        echo '<tr><td class="calendar_layout_table">Event Type:</td><td class="calendar_layout_table"><select name="event_class">';
        foreach ($GLOBALS[calendar_event_classes] as $key => $val) {
            echo '<option value="' . $key . '"';
            if ($_POST[event_class] == $key) {
                echo ' selected="selected"';
            }
            echo '>' . $val . '</option>';
        }
        echo '</select></td></tr>';
        //Start datetime
        echo '<tr><td class="calendar_layout_table">Start Time:</td><td class="calendar_layout_table">';
        echo '<select name="datetime_start_hour">';
        for ($x = 0; $x < 24; $x++) {
            echo '<option value="' . str_pad($x, 2, "0", STR_PAD_LEFT) . '"';
            if ($_POST[datetime_start_hour] == str_pad($x, 2, "0", STR_PAD_LEFT)) {
                echo ' selected="selected"';
            }
            echo '>' . str_pad($x, 2, "0", STR_PAD_LEFT) . '</option>';
        }
        echo '</select>&nbsp;:&nbsp;<select name="datetime_start_mins">';
        for ($x = 0; $x < 60;) {
            echo '<option value="' . str_pad($x, 2, "0", STR_PAD_LEFT) . '"';
            if ($_POST[datetime_start_mins] == str_pad($x, 2, "0", STR_PAD_LEFT)) {
                echo ' selected="selected"';
            }
            echo '>' . str_pad($x, 2, "0", STR_PAD_LEFT) . '</option>';
            //step by minute accuracy level
            $x += INPUT_FORM_MINUTE_ACCURACY;
        }
        echo '</select>&nbsp;&nbsp;&nbsp;';
        echo ' Date:&nbsp;<select name="datetime_start_day">';
        for ($x = 1; $x < 32; $x++) {
            echo '<option value="' . str_pad($x, 2, "0", STR_PAD_LEFT) . '"';
            if ($_POST[datetime_start_day] == str_pad($x, 2, "0", STR_PAD_LEFT)) {
                echo ' selected="selected"';
            }
            echo '>' . str_pad($x, 2, "0", STR_PAD_LEFT) . '</option>';
        }
        echo '</select>&nbsp;-&nbsp;<select name="datetime_start_month">';
        for ($x = 1; $x < 13; $x++) {
            echo '<option value="' . str_pad($x, 2, "0", STR_PAD_LEFT) . '"';
            if ($_POST[datetime_start_month] == str_pad($x, 2, "0", STR_PAD_LEFT)) {
                echo ' selected="selected"';
            }
            echo '>' . date("M", mktime(0, 0, 0, $x, 1, 2000)) . '</option>';
        }
        echo '</select>&nbsp;-&nbsp;';
        echo '<input type="text" name="datetime_start_year" maxlength="4" value="' . $_POST[datetime_start_year] . '">';
        echo '</td></tr>';
        //end datetime
        echo '<tr><td class="calendar_layout_table">End Time:</td><td class="calendar_layout_table">';
        echo '<select name="datetime_end_hour">';
        for ($x = 0; $x < 24; $x++) {
            echo '<option value="' . str_pad($x, 2, "0", STR_PAD_LEFT) . '"';
            if ($_POST[datetime_end_hour] == str_pad($x, 2, "0", STR_PAD_LEFT)) {
                echo ' selected="selected"';
            }
            echo '>' . str_pad($x, 2, "0", STR_PAD_LEFT) . '</option>';
        }
        echo '</select>&nbsp;:&nbsp;<select name="datetime_end_mins">';
        $y = 0;
        for ($x = 0; $x < 60;) {
            echo '<option value="' . str_pad($x, 2, "0", STR_PAD_LEFT) . '"';
            if ($_POST[datetime_end_mins] == str_pad($x, 2, "0", STR_PAD_LEFT)) {
                echo ' selected="selected"';
            }
            echo '>' . str_pad($x, 2, "0", STR_PAD_LEFT) . '</option>';
            //step by minute accuracy level
            $x += INPUT_FORM_MINUTE_ACCURACY;
        }
        echo '</select>&nbsp;&nbsp;&nbsp;';
        echo ' Date:&nbsp;<select name="datetime_end_day">';
        for ($x = 1; $x < 32; $x++) {
            echo '<option value="' . str_pad($x, 2, "0", STR_PAD_LEFT) . '"';
            if ($_POST[datetime_end_day] == str_pad($x, 2, "0", STR_PAD_LEFT)) {
                echo ' selected="selected"';
            }
            echo '>' . str_pad($x, 2, "0", STR_PAD_LEFT) . '</option>';
        }
        echo '</select>&nbsp;-&nbsp;<select name="datetime_end_month">';
        for ($x = 1; $x < 13; $x++) {
            echo '<option value="' . str_pad($x, 2, "0", STR_PAD_LEFT) . '"';
            if ($_POST[datetime_end_month] == str_pad($x, 2, "0", STR_PAD_LEFT)) {
                echo ' selected="selected"';
            }
            echo '>' . date("M", mktime(0, 0, 0, $x, 1, 2000)) . '</option>';
        }
        echo '</select>&nbsp;-&nbsp;';
        echo '<input type="text" name="datetime_end_year" maxlength="4" value="' . $_POST[datetime_end_year] . '">';
        echo '</td></tr>';
        //Location
        echo '<tr><td class="calendar_layout_table">Location: </td><td class="calendar_layout_table"><input type="text" name="location" value="' . $_POST[location] . '"></td></tr>' . "\n";
        //Description
        echo '<tr><td class="calendar_layout_table">Event Description:</td><td class="calendar_layout_table"><textarea name="description" rows="5" cols="40">' . $_POST[description] . '</textarea></td></tr>' . "\n";
        echo '<tr><td class="calendar_layout_table">Delete event?</td><td class="calendar_layout_table"><input type="checkbox" name="delete_event" value="y"></td></tr>' . "\n";
        //User authenication part:
        global $authenication_fields;
        foreach ($authenication_fields as $key => $val) {
            echo '<tr><td class="calendar_layout_table">' . $key . ':</td><td class="calendar_layout_table"><input type="' . $val[type] . '" name="' . $val[varname] . '"></td></tr>';
        }
        //Submit
        echo '<tr><td class="calendar_layout_table" ><input type="submit" name="event_calendar_edit_submit" value="Submit"></td><td><input type="submit" name="event_calendar_cancel_submit" value="Cancel"></td></tr>' . "\n";
        echo '</table></form>';
    } else {
        echo 'Please select the event you would like to edit:' . "<br>\n";
        //links forward and back a page
        if ($_GET[list_page] != 0) {
            echo '<a href="?' . generate_get_string() . '&list_page=' . ($_GET[list_page] - 1) . '">Previous page</a>&nbsp;&nbsp;';
        }
        if (($_GET[list_page] + 1) * EDIT_EVENT_LIST_LENGTH < events_db_count($GLOBALS[event_calendar_DB_connection])) {
            //only display next page if the full data list hasn't been reached
            echo "\t\t" . 'Displaying ' . ($_GET[list_page] * EDIT_EVENT_LIST_LENGTH + 1) . ' - ' . ($_GET[list_page] + 1) * EDIT_EVENT_LIST_LENGTH . "\t\t";
            echo '&nbsp;&nbsp;<a href="?' . generate_get_string() . '&list_page=' . ($_GET[list_page] + 1) . '">Next Page</a>' . "\n";
        } else {
            //if the final chunk of data is on screen, don't show next page
            echo "\t\t" . 'Displaying ' . ($_GET[list_page] * EDIT_EVENT_LIST_LENGTH + 1) . '-' . events_db_count($GLOBALS[event_calendar_DB_connection]);
        }
        //list of events
        create_event_list(EDIT_EVENT_LIST_LENGTH, $_GET[list_page] * EDIT_EVENT_LIST_LENGTH, LIST_DISPLAY_GET_ID_LINKS | LIST_LINKS_PRESERVE_GET_VARS | LIST_AS_TABLE);
    }
    echo '</div>';
    //end of <div class="calendar_edit_event_form">
}
示例#2
0
        create_event_list($lAdmin_tab2, true);
    }
    if ($_REQUEST["table_id"] == $sTableID_tab2) {
        $lAdmin_tab2->CheckListMode();
    }
}
//$STAT_RIGHT > "M"
$oSort_tab3 = new CAdminSorting($sTableID_tab3, "s_def", "desc");
$lAdmin_tab3 = new CAdminList($sTableID_tab3, $oSort_tab3);
$lAdmin_tab3->InitFilter($arFilterFields);
if (strlen($strError) > 0) {
    CAdminMessage::ShowMessage($strError);
} elseif ($site_filter == "Y" && $_REQUEST["table_id"] == $sTableID_tab3) {
    CAdminMessage::ShowMessage(GetMessage("STAT_NO_DATA"));
} elseif ($_REQUEST["table_id"] == $sTableID_tab3) {
    create_event_list($lAdmin_tab3);
}
if ($_REQUEST["table_id"] == $sTableID_tab3) {
    $lAdmin_tab3->CheckListMode();
}
$sTableID_tab4 = "t_visit_section_list_ENTER_COUNTER";
$lAdmin_tab4 = new CAdminList($sTableID_tab4);
$lAdmin_tab4->BeginCustomContent();
if (strlen($strError) > 0) {
    CAdminMessage::ShowMessage($strError);
} elseif ($_REQUEST["table_id"] == $sTableID_tab4) {
    ?>
Hello
<?php 
}
$lAdmin_tab4->EndCustomContent();