Location: PHPKode > projects > JaxBlog > JaxBlog/app/admin/admin_calendar/admin_calendar.php
<?php

require_once('../../../config.php');
require_once(FOLDER_RELATIVE_COMMON . 'authorization.php');
require_once(FOLDER_RELATIVE_COMMON . 'database.php');
require_once(FOLDER_RELATIVE_COMMON . 'xml.php');

$request = isset($_GET['request']) ? $_GET['request'] : '';
$stage = isset($_GET['stage']) ? $_GET['stage'] : '';

$calendar_id_1 = isset($_SESSION['id']) ? $_SESSION['id'] : null;
$calendar_id_2 = isset($_POST['calendar_id']) ? $_POST['calendar_id'] : null;
$calendar_id_3 = isset($_GET['id']);
$calendar_title = isset($_POST['calendar_title']) ? stripslashes($_POST['calendar_title']) : null;
$calendar_description = isset($_POST['calendar_description']) ? stripslashes($_POST['calendar_description']) : null;
$calendar_scheduled_date = isset($_POST['calendar_scheduled_date']) ? stripslashes($_POST['calendar_scheduled_date']) : null;

$sql_select = null;
$sql_insert = null;
$sql_update = null;

if ($request == 'xml' && $stage == 'edit') {
	$sql_select = 'SELECT id AS calendar_id, ' . databaseGetDate("scheduled_date") . ' AS calendar_scheduled_date, title AS calendar_title, description AS calendar_description FROM Calendar WHERE id = ?';
}

if ($request == 'add' && $stage == 'add') {
	$sql_insert = 'INSERT INTO Calendar (id, scheduled_date, title, description) VALUES (?, ' . databaseSetDate($calendar_scheduled_date) . ', ?, ?)';
}

if ($request == 'edit' && $stage == 'edit') {
	$sql_update = 'UPDATE Calendar SET scheduled_date = ' . databaseSetDate($calendar_scheduled_date) . ' , title = ?, description = ? WHERE id = ?';
}

$stage = processJaxFormRequest(
	$request, $stage,
	$sql_select, array($calendar_id_1), 
	$sql_insert, array(0, $calendar_title, $calendar_description), 'calendar_id_seq',
	$sql_update, array($calendar_title, $calendar_description, $calendar_id_2),
	'DELETE FROM Calendar WHERE id = ?', array($calendar_id_3),
	'location:admin_calendar_list.php');

// Show the list form.
require_once(FOLDER_RELATIVE_COMMON . 'builder-admin.php');

$header   = '<script type="text/javascript" src="admin_calendar.js"></script>' . "\n";
$onload   = "jaxFormRegister('admin_calendar.php?request=xml&stage=$stage'); initializePage();";
$title    = 'Calendar';
$content  = 'admin_calendar.html';
$page     = buildAdminPage($header, $onload, $title, $content);

echo $page;
?>
Return current item: JaxBlog