<?php

if ( !defined( 'SMARTY_DIR' ) ) {
	include_once( '../init.php' );
}
include ( 'sessioninc.php' );

define( 'PAGE_ID', 'section_mgt' );

if ( !checkAdminPermission( PAGE_ID ) ) {

	header( 'location: not_authorize.php' );
	exit;
}

$id 			= 	trim( $_POST['txtid'] );

$question 		= 	trim( $_POST['txtquestion'] ) ;

$description 	= 	trim( $_POST['txtdescription'] ) ;

$guideline 		= 	trim( $_POST['txtguideline'] ) ;

$controltype 	= 	$_POST['txtcontroltype'];

$maxlength 		= 	trim( $_POST['txtmaxlength'] );

$mandatory 		= 	$_POST['txtmandatory'];

$section 		= 	$_POST['txtsection'];

$extsearchable 	= 	$_POST['txtextsearch'];

$extsearchhead 	= 	$_POST['txextsearchhead'];

$enabled 		= 	$_POST['txtenabled'];

$gender = $_POST['txtgender'];

$err = 0;

if ( $question == '' || $maxlength == '' ) {
	$err = FIELDS_BLANK;
}

if ( $err != 0 ) {
	header ( 'location: sectionquestions.php?edit=' . $_POST['txtid'] . '&errid=' . $err );
	exit;
}

$osDB->query( "UPDATE ! SET question=?, description	=?, guideline=?,control_type=?, maxlength=?, mandatory=?, section=?, extsearchable=?, extsearchhead	=?,enabled=?, gender =? WHERE id = ?", array( QUESTIONS_TABLE, $question, $description, $guideline, $controltype, $maxlength, $mandatory, $section, $extsearchable, $extsearchhead, $enabled, $gender, $_POST['txtid'] ) );

header ( 'location: sectionquestions.php?edit=' . $_POST['txtid'] );
exit;
?>