<?php if(!isset($_SESSION)){ob_start();session_start();}header("Access-Control-Allow-Origin: *");
$ID = "message_options";
if(empty($_GET['id']))$_GET['id']="";
include("../lib/DataTables.php" );
use
	DataTables\Editor,
	DataTables\Editor\Field,
	DataTables\Editor\Format,
	DataTables\Editor\Mjoin,
	DataTables\Editor\Upload,
	DataTables\Editor\Validate;

// The following statement can be removed after the first run (i.e. the database
// table has been created). It is a good idea to do this to help improve
// performance.

$db->sql( "ALTER DATABASE CHARACTER SET utf8 COLLATE utf8_unicode_ci; ");

$db->sql( "CREATE TABLE IF NOT EXISTS `files` (
	`id` int(50) NOT NULL auto_increment,
	`filename` varchar(255),
	`filesize` varchar(255),
	`web_path` varchar(255),
	`system_path` varchar(255),
	PRIMARY KEY( `id` )
);" );



$db->sql( "CREATE TABLE IF NOT EXISTS `message_options` (
	`id` int(10) NOT NULL auto_increment,
	`type` varchar(255),
`content` varchar(255),
`after` varchar(255),
`rel` int(50),PRIMARY KEY( `id` ));");

$db->sql( "ALTER TABLE message_options CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; ");
$db->sql( "ALTER TABLE files CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; ");
Editor::inst( $db, "message_options" )
->fields(Field::inst( "message_options.id" ),
Field::inst( "message_options.rel" )
->setValue($_GET['id']),
Field::inst( "message_options.type" )->validator( 'Validate::notEmpty' )
,Field::inst( "message_options.content" )
,Field::inst( "message_options.title" )
,Field::inst( "message_options.after" )->options('bot_message','id','title' )
->validator( 'Validate::notEmpty')
,Field::inst( "bot_message_2.title"))
->leftJoin( 'bot_message bot_message_2', 'bot_message_2.id', '=', "message_options.after")
->where("message_options.rel",$_GET['id'])
->process( $_POST )
->json();?>