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


function pull_user_variables ($user_id)
{
    global $unique_seq;
    
    $sql = "SELECT gate_status, gate_login FROM gate WHERE user_id = '".$user_id."'";
    //echo '<hr>'.$sql;
    $gate_query = run_query ($sql, "No gate query");
    $gate_array = fetch_array ($gate_query, "No gate info array", "0"); 
    
    $sql = "SELECT * FROM user_info WHERE user_id = '".$user_id."'";
    $user_info_query = run_query ($sql, "No user info query");
    $user_info_array = fetch_array ($user_info_query, "No user info array", "0");
    
    $sql = "SELECT * FROM organizations WHERE org_id = '".$user_info_array["org_id"]."'";
    $org_query = run_query ($sql, "No org info query"); 
    $org_array = fetch_array ($org_query, "No org_info login query", "0"); 
    
    $sql = "SELECT * FROM groups WHERE group_id = '".$org_array["group_id"]."'";
    $group_query = run_query ($sql, "No group info query");
    $groups_array = fetch_array ($group_query, "No group info array", "0"); 
    
    $sql = "SELECT service_id FROM services_provided_by_org WHERE org_id = '".$user_info_array["org_id"]."'";
    $services_query = run_query_return_array ($sql, "No org services query", "service_id");
    
    if ( is_array($services_query) )
	{
        foreach ( $services_query as $current_service => $value )
		{
            $services_array["org_services"][$current_service] = "yes";
        }
    }
    
    $all_user_info_array = array_merge ($gate_array, $user_info_array, $org_array, $groups_array, $services_array);
    
    return $all_user_info_array;
}




function pull_associated_users ($user_id, $access_level)
{
    global $unique_seq;
                
    switch ($access_level)
	{
        case "10":
            $sql = "SELECT user_id FROM user_info WHERE user_access_level = '20'";
            $result = run_query($sql, "Associated users id 10");
            $total_matches = num_rows ($result);
            
            for ($i = 0; $i < $total_matches; $i++)
			{
                $current_row = fetch_array($result, "10 edit user function", $i);
                $associated_user[$i] = $current_row["user_id"];
            }
        break;
        
        case "20":
            $sql = "SELECT org_id FROM user_info WHERE user_id = '".$user_id."'";
            $result = run_query($sql, "Associated users id 20");
            $current_row = fetch_array($result, "Edit user function 20A", "0");
            $org_id = $current_row["org_id"];
            
            $sql = "SELECT group_id FROM organizations WHERE org_id = '".$org_id."'";
            $result = run_query($sql, "Associated users id 20");
            $current_row = fetch_array($result, "Edit user function 20B", "0");
            $group_id = $current_row["group_id"];
            
            $sqlx = "SELECT org_id FROM organizations WHERE group_id = '".$group_id."' AND org_id != '".$org_id."'";
            $result_orgs = run_query($sqlx, "Associated users id 20");
            
            $total_matches = num_rows ($result_orgs);
            for ($i = 0; $i < $total_matches; $i++)
			{
                $current_rowx = fetch_array($result_orgs, "10 edit user function", $i);
                $z_org_id = "org_id";
                $current_org = $current_rowx[$z_org_id];
                $sqlr = "SELECT user_id FROM user_info WHERE org_id = '".$current_org."' AND user_access_level LIKE '30' ";
                $resultr = run_query($sqlr, "Associated users id 20");
                $current_row = fetch_array($resultr, "Edit user function 20C", "0");
                $associated_user[$i] = $current_row["user_id"];
            }
        break;
        
        case '30':
            $sql = "SELECT org_id FROM user_info WHERE user_id = '".$user_id."'";
            $result = run_query($sql, "Associated users id 30");
            $current_row = fetch_array($result, "Edit user function 30", 0);
            $org_id = $current_row['org_id'];
            
            $sql = "SELECT user_id FROM user_info WHERE org_id = '".$org_id."' AND user_id != '".$user_id."' ORDER BY user_name_last";
            $result_users = run_query($sql, "Associated users id 30");
            
            $total_matches = num_rows ($result_users);
            for ($i = 0; $i < $total_matches; $i++)
			{
                $current_row = fetch_array($result_users, "30 edit user function", $i);
                $associated_user[$i] = $current_row["user_id"];
            }
            break;
        
        default:
        echo "No case level in edit_user_info_functions.inc";
    }
    return $associated_user;
}



function pull_associated_users_variables ($user_id, $access_level)
{
    $related_users_ids_array = pull_associated_users($user_id, $access_level);
    if($related_users_ids_array)
	{
        foreach($related_users_ids_array AS $key => $current_user_id)
		{
            $related_users_info_array[$key] = pull_user_variables($current_user_id);
            //echo $related_users_info_array[$key]["user_name_first"]."t<br>";
        }
        return $related_users_info_array;
    }
}



function display_edit_user_info_table ($user_id, $access_level)
{
    GLOBAL $head_dynamic_style, $system_directory, $group_term, $organization_term;
    $head_dynamic_style .= ".tabletop {color: #FFFFFF; font-size: 18; font-family: \"times\"; background-color: #000099; font-weight: bolder}";
    
    
    $related_user_variables = pull_associated_users_variables ($user_id, $access_level);
    
    switch($access_level.isset($related_user_variables))
	{
        case "101":
        $final_html .= "<table class=\"generictable\"><tr><td class=\"generictabletop\">".$group_term."</td><td class=\"generictabletop\">Contract #</td><td class=\"generictabletop\">Account Status</td><td class=\"generictabletop\">Link</td></tr>";
        
        foreach($related_user_variables AS $current_user_variables)
		{
            $final_html .= "<tr><td class=\"generictd\">".$current_user_variables["group_name"]."</td>";
            $final_html .= "<td class=\"generictd\">".$current_user_variables["group_contract_num"]."</td>";
            $final_html .= "<td class=\"generictd\">".ucfirst($current_user_variables["gate_status"])."</td>";
            $final_html .= "<td class=\"generictd\"><a href=\"".$system_directory."edit_user_info.php?edit_user_id=".$current_user_variables["user_id"]."\" class=\"tiny\">Click Here to Edit</a></td></tr>";
        }
        break;
        
        case "201":
        $final_html .= "<table class=\"generictable\"><tr><td class=\"generictabletop\">".$organization_term." Name</td><td class=\"generictabletop\">Account Status</td><td class=\"generictabletop\">Link</td></tr>";    
        
        foreach($related_user_variables AS $current_user_variables)
		{
            $final_html .= "<tr><td class=\"generictd\">".$current_user_variables["org_name"]."</td>";
            $final_html .= "<td class=\"generictd\">".$current_user_variables["gate_status"]."</td>";
            $final_html .= "<td class=\"generictd\"><a href=\"".$system_directory."edit_user_info.php?edit_user_id=".$current_user_variables["user_id"]."\" class=\"tiny\">Click Here to Edit</a></td></tr>";
        }
        break;
        
        case("301"):
        $final_html .= "<table class=\"generictable\"><tr><td class=\"generictabletop\">Name</td><td class=\"generictabletop\">Account Status</td><td class=\"generictabletop\">Link</td></tr>";    
        
        foreach($related_user_variables AS $current_user_variables)
		{
            $final_html .= "<tr><td class=\"generictd\">".$current_user_variables["user_name_last"].", ".$current_user_variables["user_name_first"]."</td>";
            $final_html .= "<td class=\"generictd\">".$current_user_variables["gate_status"]."</td>";
            $final_html .= "<td class=\"generictd\"><a href=\"".$system_directory."edit_user_info.php?edit_user_id=".$current_user_variables["user_id"]."\" class=\"tiny\">Click Here to Edit</a></td></tr>";
        }
        break;
        
        case "10":
        $final_html .= "<table class=\"generictable\"><tr><td class=\"generictabletop\">".$group_term."</td><td class=\"generictabletop\">Contract #</td><td class=\"generictabletop\">Account Status</td><td class=\"generictabletop\">Link</td></tr>";    
        $final_html .= "<tr><td class=\"generictd\" colspan=\"3\">No ".$group_term."s created</td></tr>";
        break;
        
        case "20":
        $final_html .= "<table class=\"generictable\"><tr><td class=\"generictabletop\">".$organization_term." Name</td><td class=\"generictabletop\">Account Status</td><td class=\"generictabletop\">Link</td></tr>";    
        $final_html .= "<tr><td class=\"generictd\" colspan=\"3\">No ".$organization_term."s created</td></tr>";
        break;
        
        case("30"):
        $final_html .= "<table class=\"generictable\"><tr><td class=\"generictabletop\">Name</td><td class=\"generictabletop\">Account Status</td><td class=\"generictabletop\">Link</td></tr>";    
        $final_html .= "<tr><td class=\"generictd\" colspan=\"3\">No Users created</td></tr>";
        break;
        
        default:
    
    }
    
    
    $final_html .= "</table>";
    
    return $final_html;
}


function edit_id_validation ($edit_user_id, $user_access_level, $org_id, $group_id)
{
    GLOBAL $question_validation_error, $message, $message_type, $unique_seq;
        
        if(ereg("[^0-9]", $new_user_id) || strlen ($new_user_id) > 5)
		{
            $message = "Illegal attempt to change ID. IP Logged. ";
            $message_type = "error";
        }
        else
		{
            //$this->pull_related_user_variables ($new_user_id);
            $user_variables = pull_user_variables ($edit_user_id);
            //display_value($user_variables);
                switch($user_access_level)
				{
                    case "10":
                        $message_type = "OK";
                        break;
                    
                    case "20":
                        $z_group_id = "group_id";
                        if($group_id != $user_variables[$z_group_id])
						{
                            $message = "Illegal attempt to change ID. IP Logged. ";
                            $message_type = "error";
                        }
                        //echo "Group id is: ".$user_variables["group_id"]."<p/>";
                        else {$message_type = "OK";}
                    break;
                    
                    case "30":
                        $z_org_id = "org_id";
                        if ($org_id != $user_variables[$z_org_id])
						{
                           $message = "Illegal attempt to change ID. IP Logged. ";
                           $message_type = "error";    
                        }
                        else {$message_type = "OK";}
                    break;
                    
                    default:
                        $message = "Illegal attempt to change ID. IP Logged. ";
                        $message_type = "error";
                }
         }
    
    return $message_type;
}


function assign_user_values_to_questions_form_blanks ($question_value_array, $question_element_array, $user_info_array)
{
    GLOBAL $organization_name;
    
    //echo 'USER INFO:'.pretty_var_dump($user_info_array);
    
    foreach ($question_value_array AS $current_question)
	{
        switch ($current_question["question_id"])
		{
            case "first_name":
                $form_answer[$current_question["question_id"]] = $user_info_array["user_name_first"];
                break;
            
            case "last_name":
                $form_answer[$current_question["question_id"]] = $user_info_array["user_name_last"];
                break;
            
            case "org_name":
                $form_answer[$current_question["question_id"]] = $user_info_array["org_name"];
                break;
            
            case "email_address":
                $form_answer[$current_question["question_id"]] = $user_info_array["user_email"];
                break;
            
            case "password":
                $form_answer[$current_question["question_id"]] = '';
                break;
            
            case "verify_password":
                $form_answer[$current_question["question_id"]] = '';
                break;
            
            case "login":
                $form_answer[$current_question["question_id"]] = $user_info_array["gate_login"];
                break;
            
            case "phone_number":
                $form_answer[$current_question["question_id"]] = $user_info_array["user_phone"];
                break;
            
            case "contract_number":
                $form_answer[$current_question["question_id"]] = $user_info_array["group_contract_num"];
                break;
            
            case "web_page_address":
                $form_answer[$current_question["question_id"]] = $user_info_array["web_page_address"];
                break;
            
            case "county_served":
                $form_answer[$current_question["question_id"]] = $user_info_array["county_served"];
                break;
            
            case "org_address":
                $form_answer[$current_question["question_id"]] = $user_info_array["org_address"];
                break;
            
            case "org_city":
                $form_answer[$current_question["question_id"]] = $user_info_array["org_city"];
                break;
            
            case "org_state":
                $form_answer[$current_question["question_id"]] = $user_info_array["org_state"];
                break;
            
            case "org_zip":
                $form_answer[$current_question["question_id"]] = $user_info_array["org_zip"];
                break;
            
            case "mailing_address":
                $form_answer[$current_question["question_id"]] = $user_info_array["mailing_address"];
                break;
            
            case "mailing_city":
                $form_answer[$current_question["question_id"]] = $user_info_array["mailing_city"];
                break;
            
            case "mailing_state":
                $form_answer[$current_question["question_id"]] = $user_info_array["mailing_state"];
                break;
            
            case "mailing_zip":
                $form_answer[$current_question["question_id"]] = $user_info_array["mailing_zip"];
                break;
            
            case "org_description":
                $form_answer[$current_question["question_id"]] = $user_info_array["org_description"];
                break;
            
            case "org_user_id":
                $form_answer[$current_question["question_id"]] = $user_info_array["org_user_id"];
                break;
            
            case "org_services":
                $form_answer[$current_question["question_id"]] = $user_info_array["org_services"];
                break;
            
            default:
        
        }
    
    }
    return $form_answer;
}




function edit_organization ($questions, $form_answer, $gate_status, $edit_user_id, $edit_org_id, $edit_group_id)
{
    GLOBAL $organization_term, $question_validation_error, $message, $message_type, $access_level, $unique_seq, $question_validation_error;
    //echo "<br>edit_organization ($questions, $form_answer, $gate_status, $edit_user_id, $edit_org_id, $edit_group_id)<br>";
    //echo pretty_var_dump(array_keys($questions));
    
    foreach ($questions as $question_value)
	{
        //echo "title is:".$question_value["question_title"]."<br>";
        switch ($question_value["question_id"])
		{
            case "first_name":
                $insert_first_name = addslashes($form_answer[$question_value["question_id"]]);
                break;
                
            case "last_name":
                $insert_last_name = addslashes($form_answer[$question_value["question_id"]]);
                break;
            
            case "org_name":
                $insert_org_name = addslashes($form_answer[$question_value["question_id"]]);
                ////$org_name_question_id = $question_value["question_id"];
                break;
            
            case "email_address":
                $insert_email = addslashes($form_answer[$question_value["question_id"]]);
                break;
            
            case "phone_number":
                $insert_phone = addslashes($form_answer[$question_value["question_id"]]);
                break;
            
            case "contract_number":
                $insert_group_contract_num = addslashes($form_answer[$question_value["question_id"]]);
                break;
            
            case "web_page_address":
                $insert_web_page_address = addslashes($form_answer[$question_value["question_id"]]);
                break;
            
            case "county_served":
                $insert_county_served = addslashes($form_answer[$question_value["question_id"]]);
                break;
            
            case "org_address":
                $insert_org_address = addslashes($form_answer[$question_value["question_id"]]);
                break;
            
            case "org_city":
                $insert_org_city = addslashes($form_answer[$question_value["question_id"]]);
                break;
            
            case "org_state":
                $insert_org_state = addslashes($form_answer[$question_value["question_id"]]);
                break;
            
            case "org_zip":
                $insert_org_zip = addslashes($form_answer[$question_value["question_id"]]);
                break;
            
            case "mailing_address":
                $insert_mailing_address = addslashes($form_answer[$question_value["question_id"]]);
                break;
            
            case "mailing_city":
                $insert_mailing_city = addslashes($form_answer[$question_value["question_id"]]);
                break;
            
            case "mailing_state":
                $insert_mailing_state = addslashes($form_answer[$question_value["question_id"]]);
                break;
            
            case "mailing_zip":
                $insert_mailing_zip = addslashes($form_answer[$question_value["question_id"]]);
                break;
            
            case "org_description":
                $insert_org_description = addslashes($form_answer[$question_value["question_id"]]);
                break;
            
            case "org_user_id":
                $insert_org_user_id = addslashes($form_answer[$question_value["question_id"]]);
                break;
            
            case "login":
                $insert_new_login = $form_answer[$question_value["question_id"]];
                $login_question_id = $question_value["question_id"];
                break;
            
            case "new_password":
	            $new_password = $form_answer[$question_value["question_id"]];
	            $new_password_question_id = $question_value["question_id"];
	            break;
            
            case "verify_password":
	            $verify_password = $form_answer[$question_value["question_id"]];
	            $verify_password_question_id = $question_value["question_id"];
	            break;
            
            case "org_services":
                $insert_org_services_array = array_keys($form_answer[$question_value["question_id"]]);
                break;
            
            default:
                echo "Question title could not be matched to question in insert_setup_group_class: ".$question_value["question_id"]."<br>";
                //exit;
        }
    }
    
    if ( !$question_validation_error )
	{
        transaction_begin ( 'Update user' );
        
        if ( $gate_status == "active" )
		{
		   $insert_gate_status = "active";
		}
        elseif ( $gate_status == "inactive" )
        {
		   $insert_gate_status = "inactive";
        }
        else
		{
		   $insert_gate_status = "pending";
		}
        
        $sql = "UPDATE user_info SET user_name_first='".$insert_first_name."', user_name_last='".$insert_last_name."', user_phone='".$insert_phone."', user_email='".$insert_email."' WHERE user_id = '".$edit_user_id."'";
        //echo 'sql1.'.$sql;
		run_query($sql, "Update user_info");
		
		//echo 'ack level.'.$access_level;
        
        if($access_level == "10" || $access_level == "20")
		{
            $sql = "UPDATE organizations SET org_name='".$insert_org_name."', account_status = '".$insert_gate_status."', web_page_address = '".$insert_web_page_address."', org_address = '".$insert_org_address."', org_city = '".$insert_org_city."', org_state = '".$insert_org_state."', org_zip = '".$insert_org_zip."', mailing_address = '".$insert_mailing_address."', mailing_city = '".$insert_mailing_city."', mailing_state = '".$insert_mailing_state."', mailing_zip = '".$insert_mailing_zip."', org_description = '".$insert_org_description."', org_user_id = '".$insert_org_user_id."' WHERE org_id ='".$edit_org_id."'";
            run_query($sql, "Update organizations");
            
            //echo $sql." change org_info<p>";
        }
		
		if($access_level == "10" || $access_level == "20" || $access_level == "30")
		{
            $sql = "UPDATE gate SET gate_status = '".$insert_gate_status."' WHERE user_id ='".$edit_user_id."'";
            run_query($sql, "Update gate");
		}
        
        if($access_level == "10")
		{
            $sql = "UPDATE groups SET group_name='".$insert_org_name."', county_served='".$insert_county_served."', group_contract_num='".$insert_group_contract_num."' WHERE group_id ='".$edit_group_id."'";
            //echo $sql."<p/>";
            run_query($sql, "Update groups");
        }
        
        if($access_level == "20")
		{
            update_org_services( $edit_org_id, $insert_org_services_array );
        }
        
        transaction_commit();
        //$message .= "User \"".$insert_first_name." ".$insert_last_name."\" sucessfully updated. ";
        $message_type = "ok";
    }
    
    //PASSWORD UPDATE BLOCK
    if ($new_password || $verify_password)
    {
        if ( $new_password != $verify_password )
        {
            question_error_marking ( $new_password_question_id, 'New password and Verify password MUST match. ' );
            question_error_marking ( $verify_password_question_id, 'New password and Verify password MUST match. ' );
        }
        
        //echo '<br>'.$insert_new_login . ' and pwd ' . $new_password;
        $pass = new Passwords ();
        $pass->check_login_and_password ( $insert_new_login, $new_password );
        if ( $pass->password_error )
        {
            question_error_marking ( $new_password_question_id, $pass->password_error );
        }
        
        /*$pass = new Passwords ();
        $pass->check_login_and_password ( $insert_new_login, $verify_password );
        if ( $pass->password_error )
        {
            question_error_marking ( $verify_password_question_id, $pass->password_error );
        }*/
        
	    if ( !$question_validation_error )
        {
		    transaction_begin ( 'Update password' );
            //$user_id_update = $this->user_id;
            
            $sql = "UPDATE gate SET gate_password='".md5 ( $new_password )."', gate_status='pending' WHERE user_id = '".$edit_user_id."'";
            run_query ($sql, "Update password");
            
            transaction_commit();
            
            //echo 'SQL:'.$sql;
            //$_SESSION['gate_status'] = 'pending';
            
		    $message .= "Password has been successfully updated. ";
            //echo $message;
		    $message_type = "ok";
	    }
     }
     //END PASSWORD UPDATE BLOCK
}







function check_for_duplicate_logins ($new_login, $current_user_id)
{
    GLOBAL $unique_seq;

    $sql = "SELECT * FROM gate WHERE gate_login LIKE '".$new_login."' AND user_id != '".$current_user_id."'";
    $matches_result = run_query ($sql, "Checking for duplicate logins");
        
    $matches = num_rows($matches_result, "Counting matching logins");
    if($matches > 0)    {
        return -1;
    } 
    else
	{
        return 1;
    }
}

function pull_access_description_based_on_access_number ($access_level)
{
    GLOBAL $group_term, $organization_term;
    switch($access_level)
	{
        case "10":
            $access_description = "System Administrator";
            break;
        
        case "20":
            $access_description = $group_term." Administrator";
            break;

        case "30":
            $access_description = $organization_term." Administrator";
            break;

        case "40":
            $access_description = "System User";
            break;

        default:
            $access_description = "Not Defined";
            break;
    }

    return $access_description;
}



function pull_organizations_info_associated_with_group ( $groupid )
{
    
    $groupid += 0;
    $sql = "SELECT * FROM organizations WHERE group_id = '".$groupid."' AND account_status = 'active'
     AND org_type != 'group' ORDER BY org_name";
    $orgs_array = run_query_return_array ( $sql, 'No associated organization', 'org_id' );
    
    return $orgs_array;
}



function pull_group_information ( $groupid )
{
    GLOBAL $unique_seq;
    $z_group_id = "group_id";
    $sqlb = "SELECT * FROM groups WHERE ".$z_group_id." = '".$groupid."'";
    //echo $sqlb;
    $group_arrayy = run_query_return_single_row ( $sqlb, 'No associated organization' );
    
    return $group_arrayy;
}





class Load_new_entity_questions
{

    function load_new_system_questions ()
	{
        $this->questions["system_name"] = array ("question_id" => "org_name", "question_title" => "System Name:<BR>", "question_type" => "text", "question_field_size" => "75", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "1019", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "40");
        
        $this->questions["first_name"] = array ("question_id" => "first_name", "question_title" => "First Name:<BR>", "question_type" => "text", "question_field_size" => "25", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "1019", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "25");
        
        $this->questions["last_name"] = array ("question_id" => "last_name", "question_title" => "Last Name:<BR>", "question_type" => "text", "question_field_size" => "25", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "1019", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "25");
        
        $this->questions["phone_number"] = array ("question_id" => "phone_number", "question_title" => "Phone Number:<BR>", "question_type" => "text", "question_field_size" => "25", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "1019", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "25");
        
        $this->questions["email_address"] = array ("question_id" => "email_address", "question_title" => "Email Address:<BR>", "question_type" => "text", "question_field_size" => "60", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "1019", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "30");
        
        $this->questions["web_page_address"] = array ("question_id" => "web_page_address", "question_title" => "Web Page Address:<BR>", "question_type" => "text", "question_field_size" => "125", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "1019", "question_required" => "no", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "40");
        
        $this->questions["login"] = array ("question_id" => "login", "question_title" => "New System Login:<BR>", "question_type" => "text", "question_field_size" => "50", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "1019", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "30");
        
        $this->questions["password"] = array ("question_id" => "password", "question_title" => "New System Password:<BR>", "question_type" => "password", "question_field_size" => "25", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "1019", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "25");
    }


    function load_new_group_questions ($is_new)
	{
        GLOBAL $group_term;
        $this->questions["group_name"] = array ("question_id" => "org_name", "question_title" => $group_term." Name:<BR>", "question_type" => "text", "question_field_size" => "75", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "10", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "40");
        
        $this->questions["contract_number"] = array ("question_id" => "contract_number", "question_title" => "Contract Number:<BR>", "question_type" => "text", "question_field_size" => "25", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "20", "question_required" => "no", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "25");
        
        $this->questions["web_page_address"] = array ("question_id" => "web_page_address", "question_title" => "Web Page Address:<BR>", "question_type" => "text", "question_field_size" => "125", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "30", "question_required" => "no", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "40");
        
         $this->questions["county_served"] = array ("question_id" => "county_served", "question_title" => "Primary County Served:<BR>", "question_type" => "text", "question_field_size" => "25", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "40", "question_required" => "no", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "25"); 
        
        $this->questions["first_name"] = array ("question_id" => "first_name", "question_title" => $group_term." Admin First Name:<BR>", "question_type" => "text", "question_field_size" => "25", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "50", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "25");
        
        $this->questions["last_name"] = array ("question_id" => "last_name", "question_title" => $group_term." Admin Last Name:<BR>", "question_type" => "text", "question_field_size" => "25", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "60", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "25");
        
        $this->questions["phone_number"] = array ("question_id" => "phone_number", "question_title" => "Phone Number:<BR>", "question_type" => "text", "question_field_size" => "25", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "70", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "25");
        
        $this->questions["email_address"] = array ("question_id" => "email_address", "question_title" => "Email Address:<BR>", "question_type" => "text", "question_field_size" => "60", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "80", "question_required" => "no", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "30");
        
        if ($is_new)
		{
            $this->questions["login"] = array ("question_id" => "login", "question_title" => "New ".$group_term."'s Login:<BR>", "question_type" => "text", "question_field_size" => "50", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "90", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "30");
            
            $this->questions["password"] = array ("question_id" => "password", "question_title" => "New ".$group_term."'s Password:<BR>", "question_type" => "password", "question_field_size" => "50", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "100", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "30");
        }
    }

    function load_new_org_questions ($is_new)
    {
        GLOBAL $organization_term;
        
        $this->questions["org_name"] = array ("question_id" => "org_name", "question_title" => $organization_term." Name:<BR>", "question_type" => "text", "question_field_size" => "75", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "10", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "40");
        
        $this->questions["web_page_address"] = array ("question_id" => "web_page_address", "question_title" => "Web Page Address:<BR>", "question_type" => "text", "question_field_size" => "125", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "20", "question_required" => "no", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "40");
        
        $this->questions["org_address"] = array ("question_id" => "org_address", "question_title" => $organization_term." Street Address:<BR>", "question_type" => "text", "question_field_size" => "75", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "30", "question_required" => "no", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "40");
        
        $this->questions["mailing_address"] = array ("question_id" => "mailing_address", "question_title" => $organization_term." Mailing Address:<BR>", "question_type" => "text", "question_field_size" => "75", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "70", "question_required" => "no", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "40");
        
        $this->questions["org_city"] = array ("question_id" => "org_city", "question_title" => "City:<BR>", "question_type" => "text", "question_field_size" => "50", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "40", "question_required" => "no", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "30");
        
        $this->questions["mailing_city"] = array ("question_id" => "mailing_city", "question_title" => "Mailing City:<BR>", "question_type" => "text", "question_field_size" => "50", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "80", "question_required" => "no", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "30");
        
        $this->questions["org_state"] = array ("question_id" => "org_state", "question_title" => "State:<BR>", "question_type" => "text", "question_field_size" => "2", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "50", "question_required" => "no", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "2");
        
        $this->questions["mailing_state"] = array ("question_id" => "mailing_state", "question_title" => "Mailing State:<BR>", "question_type" => "text", "question_field_size" => "2", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "90", "question_required" => "no", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "2");
        
        $this->questions["org_zip"] = array ("question_id" => "org_zip", "question_title" => "Zip:<BR>", "question_type" => "number", "question_field_size" => "5", "question_range_bottom" => "10000", "question_range_top" => "99999", "question_display_order" => "60", "question_required" => "no", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "3");
        
        $this->questions["mailing_zip"] = array ("question_id" => "mailing_zip", "question_title" => "Mailing Zip:<BR>", "question_type" => "number", "question_field_size" => "5", "question_range_bottom" => "10000", "question_range_top" => "99999", "question_display_order" => "100", "question_required" => "no", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "3");
        
        $this->questions["org_description"] = array ("question_id" => "org_description", "question_title" => $organization_term." Description:", "question_type" => "textarea", "question_field_size" => "4", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "110", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "40");
        
        $this->questions["org_services"] = array ("question_id" => "org_services", "question_title" => $organization_term." Services:", "question_type" => "checkboxes", "question_field_size" => "", "question_range_bottom" => "", "question_range_top" => "", "question_display_order" => "120", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "");
        
        $active_services = get_active_services_array();
        
        foreach ($active_services as $current_service)
		{
            $this->question_elements["org_services"][$current_service["service_id"]] = array ("question_element_id" => $current_service["service_id"], "question_id" => "org_services", "question_element_title" => $current_service["service_display_term"], "question_element_value" => $current_service["service_id"]);
        }
        
        $this->questions["first_name"] = array ("question_id" => "first_name", "question_title" => $organization_term." Admin First Name:<BR>", "question_type" => "text", "question_field_size" => "25", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "130", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "25");
        
        $this->questions["last_name"] = array ("question_id" => "last_name", "question_title" => $organization_term." Admin Last Name:<BR>", "question_type" => "text", "question_field_size" => "25", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "140", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "25");
        
        $this->questions["phone_number"] = array ("question_id" => "phone_number", "question_title" => "Phone Number:<BR>", "question_type" => "text", "question_field_size" => "25", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "150", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "25");
        
        $this->questions["email_address"] = array ("question_id" => "email_address", "question_title" => "Email Address:<BR>", "question_type" => "text", "question_field_size" => "60", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "160", "question_required" => "no", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "30");
        
        if ($is_new)
		{
            $this->questions["login"] = array ("question_id" => "login", "question_title" => "New ".$organization_term."'s Login:<BR>", "question_type" => "text", "question_field_size" => "50", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "170", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "30");
            
            $this->questions["password"] = array ("question_id" => "password", "question_title" => "New ".$organization_term."'s Password:<BR>", "question_type" => "password", "question_field_size" => "50", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "180", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "30");
        }
        
        $this->questions["org_user_id"] = array ("question_id" => "org_user_id", "question_title" => $organization_term."'s ID:<BR>", "question_type" => "text", "question_field_size" => "50", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "190", "question_required" => "no", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "30");
    }

    function load_new_user_questions ($is_new)
	{
        $this->questions["first_name"] = array ("question_id" => "first_name", "question_title" => "First Name:<BR>", "question_type" => "text", "question_field_size" => "25", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "1019", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "25");
        
        $this->questions["last_name"] = array ("question_id" => "last_name", "question_title" => "Last Name:<BR>", "question_type" => "text", "question_field_size" => "25", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "1019", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "25");
        
        $this->questions["phone_number"] = array ("question_id" => "phone_number", "question_title" => "Phone Number:<BR>", "question_type" => "text", "question_field_size" => "25", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "1019", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "25");
        
        $this->questions["email_address"] = array ("question_id" => "email_address", "question_title" => "Email Address:<BR>", "question_type" => "text", "question_field_size" => "60", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "1019", "question_required" => "no", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "30");
        
        if ($is_new)
		{
            $this->questions["login"] = array ("question_id" => "login", "question_title" => "New User's Login:<BR>", "question_type" => "text", "question_field_size" => "50", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "1019", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "30");
            
            $this->questions["password"] = array ("question_id" => "password", "question_title" => "New User's Password:<BR>", "question_type" => "password", "question_field_size" => "50", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "1019", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "30");
            
            $this->questions["verify_password"] = array ("question_id" => "verify_password", "question_title" => "Verify Password:<BR>", "question_type" => "password", "question_field_size" => "50", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "30", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "30");
        }
        else
        {
            $this->questions["new_password"] = array ("question_id" => "new_password", "question_title" => "Change User's Password (leave blank to keep current password):<BR>", "question_type" => "password", "question_field_size" => "50", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "1019", "question_required" => "no", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "30");
            
            $this->questions["verify_password"] = array ("question_id" => "verify_password", "question_title" => "Verify Password Change (leave blank to keep current password):<BR>", "question_type" => "password", "question_field_size" => "50", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "30", "question_required" => "no", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "30");
            
            $this->questions["login"] = array ("question_id" => "login", "question_title" => "Change User's Login:<BR>", "question_type" => "text", "question_field_size" => "50", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "1019", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "30");
        }
    }

    function load_update_password_questions ()
	{
        $this->questions["existing_password"] = array ("question_id" => "existing_password", "question_title" => "Existing Password:<BR>", "question_type" => "password", "question_field_size" => "50", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "10", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "30");
        
        $this->questions["new_password"] = array ("question_id" => "new_password", "question_title" => "New Password:<BR>", "question_type" => "password", "question_field_size" => "50", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "20", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "30");
        
        $this->questions["verify_password"] = array ("question_id" => "verify_password", "question_title" => "Verify Password:<BR>", "question_type" => "password", "question_field_size" => "50", "question_range_bottom" => "0", "question_range_top" => "0", "question_display_order" => "30", "question_required" => "yes", "question_default_value" => "", "question_visible" => "yes", "question_ecma" => "", "question_display_size" => "30");
    }

}//end of Load_new_entity_questions class

?>
Return current item: Homeless Mangement Information System