<?php
//*Client Data System, Copyright (C) 2000, 2001 Tedd Kelleher. This is free software, subject to the
//*GNU GENERAL PUBLIC LICENSE, Version 2, June 1991 (in file named gpl.txt), which should accompany
//*any distribution of this file. Tedd Kelleher can be contacted at hide@address.com
$page_title = "Query Build";
$page_access_levels = ":10:";
$page_id = "query_report";
$page_profile = "Query Client Data";
$instructions .= "Query client data by selecting parameters below. ";
////Header for every page that finds the include directory, connects to db, authenticates user access
include("initialize_pointer.php");
if(!include($include_root."authenticate.inc")){echo "No Authentication"; exit; };
include($include_root."Questions_into_array_class.inc");
include($include_root."questions_display.inc");
include($include_root."Questions_answers_validation_class.inc");
//include($include_root."questions_into_tags_function.inc");
include($include_root."head.inc");
include($include_root."template_parser.inc");
include($include_root."page_elements_display.inc");
//include($include_root."client_id_class.inc");
//include($include_root."client_report_entry_class.inc");
//include($include_root."client_profile_class.inc");
include($include_root."reports_class.inc");
include($include_root."report_date_questions_class.inc");
//include($include_root."relationships_class.inc");
include($include_root."query_class.inc");
include($include_root."query_build.inc");
$html_template = "generic_form.html";
$build = new Query_build;
$build->define_query_build_questions();
convert_post_and_get_variable ("edit_query");
if( ereg("[^0-9a-z\_]", $edit_query) )
{
echo "Illegal edit_query name";
unset($edit_query);
}
if ( $edit_query )
{
$valid_form_answers = $build->return_values_for_edit($edit_query);
}
elseif ( $form_submitted )
{
//convert query title to all lower case ~jeff
$form_answer["query_title"] = strtolower($form_answer["query_title"]);
$validation = new Questions_answers_validation($build->query_build_questions, $build->query_build_question_elements, $form_answer);
//Since SQL statements have all sorts of disallowed characters, bypass the normal check (OK since this is only accessed as system administrator)
//$form_answer["query_sql"] = str_replace ("\\", "", $form_answer["query_sql"] );
secondary_form_answer_validation ("Query SQL", "query_sql", $form_answer["query_sql"], 15,
"A-Za-z0-9\)\[:space:]\(\.\,\'\/\=\_\>\<\*\}\{\+\#\-", 100000 );
secondary_form_answer_validation ("Client list template", "client_list_elements_template",
$form_answer["client_list_elements_template"], '',
"A-Za-z0-9\)\[:space:]\(\.\,\/\=\:\_\>\<\}\{\-", 1000 );
//"A-Za-z0-9\)\[:space:]\(\.\?\,\"\!\#\%\'\&\$\;\@\/\=\:\_\>\<\*\-"
/////$validation->vetted_form_answer["query_sql"] = $form_answer["query_sql"];
/////$validation->vetted_value["query_sql"] = $form_answer["query_sql"];
$valid_form_answers = $validation->vetted_form_answer;
if ( !$question_validation_error )
{
$build->insert_query_build_answers ($validation->vetted_value);
}
}
$list = new Query_list;
$tag_values["QUERY_BUILD_FORM_TABLE"] = $build->make_sql_build_form_html ($valid_form_answers);
$tag_values["QUERY_BUILD_EXISTING_QUERIES_LIST"] = $list->query_list_table ();
//Define the values for tags contained in the html template
$tag_values["{FORM_START}"] = form_start ($this_page);
$tag_values["{FORM_END}"] .= ' ';//form_end ("Submit Form", 1);
$tag_values["{PAGE TITLE}"] = page_title_table();
$tag_values["{MENU}"] = menu();
$tag_values["{HEAD}"] = head ($page_title, $head_page_specific, $head_dynamic_style);
$tag_values["{FOOTER}"] = footer();
//echo "Template is: ".$html_template."<br>";
template_parser ($html_template, $tag_values);
//include($include_root."variables.inc");
?>