<?php

include('../include/session.php');

date_default_timezone_set('Africa/Gaborone');
$date_time = date("Y-m-d H:i:s", time()); 

$title = $_GET['title_text'];
$module = $_GET['module_select'];
$description = $_GET['description_text'];

$description_string=$description;			
$description_string = str_replace("'", "-", $description_string);
$description_string = htmlentities($description_string, ENT_QUOTES);

$username = $_GET['user_select'];
if (isset($_GET['importance_checkbox'])) { $importance = 'yes'; } else {$importance = 'no';}

$increment_query = 'ALTER TABLE dpt_error_log AUTO_INCREMENT=1000';
execsql($increment_query);

$table_name = $_SESSION['db_prefix']."_error_log";
$log_query = "INSERT INTO $table_name (error_report_date, error_module, error_title, error_description, error_reported_by, error_importance, error_entered_by) VALUES ('".$date_time."', '".$module."', '".$title."', '".$description_string."', '".$username."', '".$importance."', '".$_SESSION['username']."') ";
execsql($log_query);



if (isset($_GET['save_close_button']) )
	   { ?>
       <script>
	 		 window.location="user_list.php";
		</script>
        <?php		 
	   }
	   
	if (isset($_GET['save_new_button']) )
	   {  ?>
       <script>
	          window.location="new_error.php"
	   </script>
        <?php		 
	   }
	   ?>