Location: PHPKode > projects > Homeless Mangement Information System > hmis/include/system_critique.php
<?php
///////////ERASE THIS!, worng location!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//*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 = "System Critique";
$page_access_levels = ":10:20:30:40:";
//$page_id = "index";
//$page_profile = "Homepage";
$instructions .= "System critiques are listed 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_report_class.inc");

convert_post_and_get_variable($critique_page_url);
echo "here it is<p>";
display_value ($critique_page_url);

switch($form_submitted)	{
	
	case "default_critique":
		process_critique_new_submission ($form_answer);
	echo "default_critique switch<br>";

		break;

	default:
		display_default_critique_page ($critique_page_url, "yes");
		echo "default switch AA<br>";

}

 /*

//Pull new critique questions
$critique_new_questions = new Critique;
$critique_new_questions->critique_new_questions ($critique_page_url);

//Pull new critique questions
$critique_entry_questions = new Critique;
$critique_entry_questions->critique_entry_questions ();

if($form_submitted)	{

	//Validate new critique questions
	$validation_critique_new_questions = new Questions_answers_validation($critique_new_questions->questions, $critique_new_questions->question_elements, $form_answer);

	//Validate new critique entry questions
	$validation_critique_entry_questions = new Questions_answers_validation($critique_entry_questions->questions, $critique_entry_questions->question_elements, $form_answer);

	if(!$question_validation_error)	{
		
		$inserted_critique_id = $critique_new_questions->insert_critique_new_questions ($validation_critique_new_questions->vetted_value);

		$critique_entry_questions->insert_critique_entry ($inserted_critique_id, $validation_critique_entry_questions->vetted_value);

									}

					}







$html_template = "generic_form.html";
*/
//Define the values for tags contained in the html template

$tag_values["{FORM_START}"] = form_start ();
$tag_values["{FORM_END}"] .= form_end ("Submit Report", 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();


template_parser ($html_template, $tag_values);

////////////////////////////////////
//Functions

function display_default_critique_page ($critique_page_url, $fresh="")	{

	GLOBAL $tag_values, $page_id, $html_template, $validation_critique_new_questions, $validation_critique_entry_questions;

	$page_id = "default_critique";
	$html_template = "system_critique.html";

	//Pull new critique questions
	$critique_new_questions = new Critique;
	$critique_new_questions->critique_new_questions ($critique_page_url);

	//Pull new critique questions
	$critique_entry_questions = new Critique;
	$critique_entry_questions->critique_entry_questions ();
	
	if($fresh == "yes")	{
echo "Fresh is YES<br>";
		
		$validation_critique_new_questions->vetted_form_answer = "";
		$validation_critique_entry_questions->vetted_form_answer = "";
		
						}

	//New critique questions into tags
	questions_into_tags ($critique_new_questions->questions, $critique_new_questions->question_elements, $validation_critique_new_questions->vetted_form_answer);

	//New critique entry questions into tags
	questions_into_tags ($critique_entry_questions->questions, $critique_entry_questions->question_elements, $validation_critique_entry_questions->vetted_form_answer);

	$tag_values["{MATCHING_OPEN_ENTRIES_TABLE}"] = display_table_of_entries("matching", $critique_page_url);
	$tag_values["{OPEN_ENTRIES_TABLE}"] = display_table_of_entries("open");
	$tag_values["{FORM_END}"] .= display_hidden_form_values ("critique_page_url", $critique_page_url);

													}

function process_critique_new_submission ($form_answer)	{
	GLOBAL $question_validation_error, $validation_critique_new_questions, $critique_page_url, $validation_critique_entry_questions;

	//Pull new critique questions
	$critique_new_questions = new Critique;
	$critique_new_questions->critique_new_questions ($critique_page_url);

	//Pull new critique questions
	$critique_entry_questions = new Critique;
	$critique_entry_questions->critique_entry_questions ();

	//Validate new critique questions
	$validation_critique_new_questions = new Questions_answers_validation($critique_new_questions->questions, $critique_new_questions->question_elements, $form_answer);

	//Validate new critique entry questions
	$validation_critique_entry_questions = new Questions_answers_validation($critique_entry_questions->questions, $critique_entry_questions->question_elements, $form_answer);

	if(!$question_validation_error)	{
		
		$inserted_critique_id = $critique_new_questions->insert_critique_new_questions ($validation_critique_new_questions->vetted_value);

		$critique_entry_questions->insert_critique_entry ($inserted_critique_id, $validation_critique_entry_questions->vetted_value);

		display_default_critique_page ($critique_page_url, "yes");

									}
	else	{
		display_default_critique_page ($critique_page_url, "no");

			}


														}





class Critique	{
var $questions;
var $question_elements;
var $critique_id;

	function insert_critique_new_questions ($vetted_values)	{
		global $unique_seq;
        
		$sql = "INSERT INTO critiques (critique_title, critique_type, critique_status, critique_page_url) VALUES ('".$vetted_values["critique_title"]."', '".$vetted_values["critique_type"]."', 'open', '".$vetted_values["critique_page_url"]."')";
		run_query($sql, "Insert new critiqueA");

		$sql = "SELECT ".$unique_seq."critique_rowid FROM critiques WHERE critique_title LIKE '".$vetted_values["critique_title"]."' AND critique_type LIKE '".$vetted_values["critique_type"]."' AND critique_status LIKE 'open' ORDER BY  ".$unique_seq."critique_rowid DESC";
		
		$result = run_query($sql, "Insert new critiqueB");

		$this->critique_id = fetch_result($result, "New critique rowid");


		$sql = "UPDATE critiques SET critique_id='".$this->critique_id."' WHERE ".$unique_seq."critique_rowid = '".$this->critique_id."' ";
		run_query($sql, "Insert new critique id C");

		return $this->critique_id;

															}

	function insert_critique_entry ($critique_id, $vetted_value)	{
		GLOBAL $unix_date, $user_id;

		$sql = "INSERT INTO critique_entries (critique_id, critique_user_id, critique_priority, critique_comment, critique_date) VALUES ('".$critique_id."', '".$user_id."', '".$vetted_value["critique_priority"]."', '".$vetted_value["critique_comment"]."', '".$unix_date."')";
		run_query($sql, "Insert new critique entry B");


		$sql = "SELECT SUM(critique_priority) FROM critique_entries WHERE critique_id = '".$critique_id."'";
		$result = run_query($sql, "Sum critique entries priorities A");
		$score = fetch_result($result, "Sum critique entries priorities B");
		$sql = "UPDATE critiques SET critique_score='".$score."' WHERE critique_id = '".$critique_id."' ";
		run_query($sql, "Insert new critique score");
		

																	}

		





	function critique_new_questions ($critique_page_url)	{
		GLOBAL $unix_date;
		$critique_page_url = htmlspecialchars($critique_page_url);
		$critique_page_url = addslashes($critique_page_url);
						

		$this->questions["critique_title"] = array ("question_id" => "critique_title", "question_title" => "One Sentance Description:", "question_type" => "text", "question_owner_group_id" => "1", "question_owner_org_id" => "1", "question_field_size" => "100", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "1019", "question_required" => "yes", "question_page_id" => "critique_new", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "");

		$this->questions["critique_page_url"] = array ("question_id" => "critique_page_url", "question_title" => "Critique Page Address:", "question_type" => "text", "question_owner_group_id" => "1", "question_owner_org_id" => "1", "question_field_size" => "200", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "1019", "question_required" => "no", "question_page_id" => "critique_new", "question_default_value" => $critique_page_url, "question_visible" => "yes", "question_ecma" => "");

		$this->questions["critique_type"] = array ("question_id" => "critique_type", "question_title" => "Report Type:", "question_type" => "radio", "question_field_size" => "0", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "1019", "question_required" => "yes", "question_default_value" => "bug", "question_visible" => "yes", "question_ecma" => "");

			$this->question_elements["critique_type"]["bug"] = array ("question_element_id" => "critique_type_bug", "question_id" => "critique_type", "question_element_title" => "Bug", "question_element_value" => "bug");

			$this->question_elements["critique_type"]["feature"] = array ("question_element_id" => "critique_type_feature", "question_id" => "critique_type", "question_element_title" => "Feature", "question_element_value" => "feature");

										}

		
	function critique_entry_questions ()	{
		GLOBAL $unix_date;
						
		$this->questions["critique_comment"] = array ("question_id" => "critique_comment", "question_title" => "Comment:", "question_type" => "text", "question_owner_group_id" => "1", "question_owner_org_id" => "1", "question_field_size" => "250", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "1019", "question_required" => "no", "question_page_id" => "critique_new", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "");

		$this->questions["critique_priority"] = array ("question_id" => "critique_priority", "question_title" => "Report Priority:", "question_type" => "radio", "question_field_size" => "0", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "1019", "question_required" => "yes", "question_default_value" => "2", "question_visible" => "yes", "question_ecma" => "");

			$this->question_elements["critique_priority"]["4"] = array ("question_element_id" => "critique_priority_very_high", "question_id" => "critique_priority", "question_element_title" => "Very High: I cannot use the system if this is not addressed.", "question_element_value" => "4");

			$this->question_elements["critique_priority"]["3"] = array ("question_element_id" => "critique_priority_high", "question_id" => "critique_priority", "question_element_title" => "High: The system is hard to use if this is not addressed.", "question_element_value" => "3");

			$this->question_elements["critique_priority"]["2"] = array ("question_element_id" => "critique_priority_medium", "question_id" => "critique_priority", "question_element_title" => "Medium: I want this addressed, but I can work around it.", "question_element_value" => "2");

			$this->question_elements["critique_priority"]["1"] = array ("question_element_id" => "critique_priority_low", "question_id" => "critique_priority", "question_element_title" => "Low: It would be nice if this was addressed.", "question_element_value" => "1");

			
											}

				}		

function display_table_of_entries ($table_type, $critique_page_url="")	{
			
	switch ($table_type)	{

		case "matching":
			$report_select_sql = "SELECT * FROM critiques WHERE critique_status IN ('open', 'analyzed') AND critique_page_url LIKE '".$critique_page_url."'";
			$header_html = "Existing Reports With the Same Page Address as the Last Page You Were Viewing";
			break;

		default:
			$report_select_sql = "SELECT * FROM critiques WHERE critique_status IN ('open', 'analyzed')";
			$header_html = "All Open Reports";
			
							}
	

	$result = run_query($report_select_sql, "Display Critiques");

	$final_html .= "<table>";
	$final_html .= "<tr><td colspan=\"6\" class=\"generictabletop\">".$header_html."</td></tr>";

	$final_html .= "<tr>";
	$final_html .= "<td><h5>Report Title</h5></td>";
	$final_html .= "<td><h5>Report Type</h5></td>";
	$final_html .= "<td><h5>Report Originator</h5></td>";
	$final_html .= "<td><h5>Status</h5></td>";
	$final_html .= "<td><h5>Report Page Address</h5></td>";
	$final_html .= "<td><h5>Report Score</h5></td>";
	$final_html .= "</tr>";

	$row_count = num_rows($result);

	if($row_count > 0)	{ 
	for($c = 0; $c < $row_count; $c++)	{

		$row_array = fetch_array($result, "Display critique table B", $c);

		$final_html .= "<tr>";
		$final_html .= "<td>".$row_array["critique_title"]."</td>";
		$final_html .= "<td>".$row_array["critique_type"]."</td>";
		$final_html .= "<td>".$row_array["critique_author"]."</td>";
		$final_html .= "<td>".$row_array["critique_status"]."</td>";
		$final_html .= "<td><h6>".$row_array["critique_page_url"]."</h6></td>";
		$final_html .= "<td>".$row_array["critique_score"]."</td>";
		$final_html .= "</tr>";
										}
						}
		else {$final_html .= "<tr><td colspan=\"6\">No Reports</td></tr>";}

	$final_html .= "</table><p></p>";

	return $final_html;

											}

?>
Return current item: Homeless Mangement Information System