Location: PHPKode > projects > Homeless Mangement Information System > hmis/client_editprofile.php
<?php
//*Client Data System, Copyright (C) 2000, 2001, 2002, 2003 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_id = "clients";
$page_access_levels = ':40:';
//$page_profile = "View Client Information";

////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_id_org_generated_class.inc");
include($include_root."client_profile_class.inc");
include($include_root."reports_class.inc");
include($include_root."insert_household_report_class.inc");  //needed for edit profile
include($include_root."relationships_class.inc");
include($include_root."insert_client_report_class.inc");
include ( $include_root.'encryption_class.inc' );
include ( $include_root.'client_lookup_class.inc' );
include ( $include_root.'date_encrypted_functions.inc' );

convert_post_and_get_variable ( 'edit_client_identifiers_for_client_id' );
convert_post_and_get_variable ( 'form_submitted' );

//echo "this_page: ".$this_page."<br>";
//echo "template: ".$html_template."<br>";
//var_dump($edit_client_identifiers_for_client_id);
//echo "<br>";
//echo "<p><font color=purple size=2>form_submitted: ";
//echo pretty_var_dump($form_submitted);
//var_dump($edit_client_identifiers_for_client_id);
//echo "</p></font>";

//reset values
$message = '';
$message_type = 'ok';

if ( $form_submitted == 'client_ids_edit' )
{
	//the message is overwritten below if there is an error
	$message = "Client Identifiers/Profile successfully edited. ";
    $message_type = "ok";
}


if ( $edit_client_identifiers_for_client_id ) //Edit Client Profile Form
{
    if ( ereg ( '[^0-9]', $edit_client_identifiers ) ) 
    {
       echo 'Illegal non-numeric client id'; exit;
    }
    //echo 'In edit cli ids<p>';
    
    $id_quests = new Client_id;
	$id_quests->pull_client_id_entry_questions_array ( '0' );
    $clup = new Client_lookup; 
    
    if ( $form_answer )
    {
        $validated_iden_ans = new Questions_answers_validation ( $id_quests->questions, $id_quests->question_elements, $form_answer );
        $client_ids = $validated_iden_ans->vetted_form_answer;
        $whole_question_set_attributes = $id_quests->questions;

        if ( !$question_validation_error )
        {
           $id_quests->insert_edited_client_id ( $edit_client_identifiers_for_client_id, $validated_iden_ans->vetted_value, $org_id );
		   //Note: Must pull all related clients as they must go along for the ride so that client relationship to HOH 
		   //is maintained in new client_profile report.
           $rel = new Relationships ( $edit_client_identifiers_for_client_id );
		   
		   //The View ($client_info) currently only contains the client being edited $client_info[0] and is updated with the edited info.
		   //But before $client_info is passed on to be inserted into the profile reports we must gather up all relations as they must go
		   //along for the ride.
		   if (is_array($rel->related_clients_profile_array))
		   {
		     foreach ( $rel->related_clients_profile_array AS $key => $cli_array )
		     {
		   		if ($cli_array['client_id']!=$edit_client_identifiers_for_client_id)
				{
					array_push ( $client_info, $cli_array );
				}
		     }
		   }
		   //echo "client_info to pass along".pretty_var_dump($client_info);
		   //Now ready to insert the edited profile and all related unedited profiles so their report id gets updated too...
           $insert_profile = new Client_profile;
           $insert_profile->insert_client_profile_answers ('client_profile', $client_info, $whole_question_set_attributes); //, '', 'edit'); //$whole_question_set_attributes);
		   $message = "Client Identifiers/Profile edit succeeded. ";
        }
        else //error
        {
            $message = "Client Identifiers/Profile edit failed.  See error below.";
        }
    }
    else
    {
        $client_ids = $clup->pull_related_org_identifiers ( $edit_client_identifiers_for_client_id, $org_id, '0' );
    }
    
    //echo "<br>client ids:".pretty_var_dump($client_ids);
    //Now render Client profile Edit form...
    display_client_identifiers_edit_form ( $edit_client_identifiers_for_client_id, $client_ids );
    //var_dump ($client_ids);
    //$matching_clients_identifier_array = $clup->lookup_client_using_identifiers ( $id_quests->questions, $exisiting_client_ids );
    //echo 'matchin array<p>'; echo pretty_var_dump ( $matching_clients_identifier_array ); echo '<p>';
    //$tag_values['{MATCHING_CLIENTS}'] = display_clients_matching_identifier_lookup ( $matching_clients_identifier_array );
    $tag_values['{FORM_END}'] .= display_hidden_form_values	( 'edit_client_identifiers_for_client_id', $edit_client_identifiers_for_client_id );
    $tag_values['{FORM_END}'] .= form_end ($button_label, 1);
	
	//Since user is editing existing data, even if there is an error, you want to allow 'nevermind' button for backout.
	$tag_values['{FORM_END}'] .= edit_button (1);
}

//echo pretty_var_dump($_SERVER);
//echo pretty_var_dump($_SESSION);

//Define the values for tags contained in the html template
$tag_values["{FORM_START}"] = form_start ( $form_action );
//$tag_values["{FORM_END}"] .= form_end ($button_label, 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);



function display_client_identifiers_edit_form ( $client_id, $vetted_system_id_form_answer = '', $status=0 )
{
	GLOBAL $page_id, $html_template, $tag_values, $button_label, $page_title, $instructions; 
    
	$page_title = 'Edit client identifiers';
    $instructions .= 'Change client identifiers by changing the values below. ';
    $id_system = new Client_id;
	$id_system->pull_client_id_entry_questions_array ( '0', 'yes' );
    
	$page_id = 'client_ids_edit';
	$html_template = 'client_lookup.html';
	
    //$profile = new Client_profile;  -- might not make sense to use this since data in client_info may be decremented
    $cli_lkup = new Client_lookup;
	//Note: Get latest info from db rather than using session side client_info which could be out of date
    $cli_vars = $cli_lkup->pull_id_reports_matching_for_client ( $client_id );  
	
	//$client_variables[0] = $selected_client_variables;
    //$holder[$cli_vars['client_id']][2] = $cli_vars;
	//echo "<br>cli_vars:".pretty_var_dump($cli_vars);
    
    //Build the html for the client id entry page
    $tag_values['{CLIENT IDENTIFIER ENTRY TABLE}'] .= ' ';
    //client', 'do not show links', 'yes' ).'<br>';
	$tag_values['{CLIENT IDENTIFIER ENTRY TABLE}'] .=
     $id_system->assemble_client_system_id_lookup_entry_table ( $vetted_system_id_form_answer, 'Edit client identifiers below' );
    $tag_values['{MATCHING_CLIENTS}'] = ' ';
    $tag_values['{CLIENT_PROFILE}'] = display_client_identifiers_table ( $cli_vars, 'Clients identifiers used for this
    client', 'do not show links' );
    $tag_values['{RELATIONSHIPS}'] = ' '; 
	//Build the html for the client id entry page
    log_report_activity ( $_SESSION['user_idB'], 'identifier', $_SESSION['org_idB'], 'id_edit' );
	
	$button_label = 'Press to submit edited client identifiers';
}

?>
Return current item: Homeless Mangement Information System