Location: PHPKode > projects > Homeless Mangement Information System > hmis/include/Insert_data_setup_group.inc
<?php

class  Insert_data_setup_group	{
	
	var $questions;
	var $form_answer;
	var $group_name;
	var $group_contract_num;
	var $group_org_name;
	var $org_system_type;
	var $user_access_level;
	var $user_name_first;
	var $user_name_last;
	var $user_phone;
	var $user_email;
	
	function Insert_data_setup_group ($questions, $form_answer, $group_name, $group_contract_num, $group_org_name, $org_system_type, $user_access_level, $user_name_first, $user_name_last, $user_phone, $user_email)	{
        global $unique_seq;
		$this->questions = $questions;
		$this->form_answer = $form_answer;
		$this->group_name = $group_name;
		$this->group_contract_num = $group_contract_num;
		$this->group_org_name = $group_org_name;
		$this->org_system_type = $org_system_type;
		$this->user_access_level = $user_access_level;
		$this->user_name_first = $user_name_first;
		$this->user_name_last = $user_name_last;
		$this->user_phone = $user_phone;
		$this->user_email = $user_email;

		foreach ($this->questions as $question_value)	{
			echo "title is:".$question_value["question_title"]."<br>";
			switch ($question_value["question_title"])	{

				case "First Name:":
					$insert_first_name = $form_answer[$question_value["question_id"]];
					echo "FIRST".$this->form_answer[$question_value["question_id"]];
					break;
					
				case "Last Name:":
					$insert_last_name = $form_answer[$question_value["question_id"]];
					break;

				case "Organization Name:":
					$insert_org_name = $form_answer[$question_value["question_id"]];
					break;

				case "Email Address:":
					$insert_email = $form_answer[$question_value["question_id"]];
					break;

				case "Phone Number:":
					$insert_email = $form_answer[$question_value["question_id"]];
					break;

				case "Enter New Login:":
					$insert_new_login = $form_answer[$question_value["question_id"]];
					break;

				case "Enter New Password:":
					$insert_new_password = $form_answer[$question_value["question_id"]];
					break;

				default:
					echo "Question title could not be matched to question"; exit;
														}	

														}
		//Set-up Group
		$sql = "INSERT INTO groups (group_id, group_name, group_contract_num) VALUES ('".$this->group_name."', '".$this->group_contract_num."')";
		run_query ($sql, "groups table creation");
		
		//Set-up organizations
		$sql = "SELECT group_id FROM groups WHERE group_name LIKE '".$this->insert_group_name."' AND group_contract_num LIKE '".$this->insert_group_contract_num."'";
		$last_insert = run_query ($sql, "gate insert id select");

		$group_id_insert = fetch_result ($last_insert, "gate user id");

		$sql = "INSERT INTO organizations (org_name, group_id, org_system_type) VALUES ('".$this->insert_org_name."', '".$group_id_insert."', '".$this->insert_org_system_type."')";
		run_query ($sql, "organizations creation");
		
		//Set-up gate
		$sql = "SELECT org_id FROM organizations WHERE group_id LIKE '".$group_id_insert."'";
		$last_insert = run_query ($sql, "gate insert id select");
		
		$last_org_id_insert = fetch_result ($last_insert, "gate user id");

		$sql = "INSERT INTO gate (gate_login, gate_password, gate_status) VALUES ('".$this->insert_new_login."', '".$this->insert_new_password."', 'active')";
		run_query ($sql, "gate insertion");

		$sql = "SELECT user_id FROM gate WHERE gate_login LIKE '".$this->insert_new_login."' AND gate_password LIKE '".$this->insert_new_password."'";
		$last_insert = run_query ($sql, "gate insert id select");
		
		$last_user_id_insert = fetch_result ($last_insert, "gate user id");

		$sql = "INSERT INTO user_info (user_id, user_access_level, org_id, user_name_first, user_name_last, user_phone, user_email) VALUES ('".$last_user_id_insert."', '".$this->access_level."', '".$this->org_id."', '".$this->insert_first_name."', '".$this->insert_last_name."', '".$this->insert_phone_num."', '".$this->insert_email."')";
		run_query ($sql, "user_info creation");
			
							}
								}

	


					


?>
Return current item: Homeless Mangement Information System