<?php
//*Client Data System, Copyright (C) 2000, 2001, 2002 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
//NOTE: THIS FILE IS NOW ONLY USED FOR "CREATE NEW CLIENTS"... REPORT.PHP HANDLES ALL OTHER CLIENT FORMS... TODO: More clean up to do here!
$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."question_set_validation_function.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_class.inc");
include($include_root."insert_household_report_class.inc");
include($include_root."insert_client_report_class.inc");
if ( !include ($include_root."client_profile_class.inc") ) { include_once($include_root."client_profile_class.inc"); }
//include($include_root."client_profile_class.inc");
include($include_root.'client_lookup_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."user_info_functions.inc");
include($include_root."referrals_class.inc");
include($include_root."encryption_class.inc");
include($include_root."date_encrypted_functions.inc");
include($include_root."services_functions.inc");
convert_post_and_get_variable ('report_name');
convert_post_and_get_variable ('report_unit');
convert_post_and_get_variable ('form_answer_added_client');
convert_post_and_get_variable ('empty_form');
convert_post_and_get_variable ('ref_to_org_id');
convert_post_and_get_variable ( 'edit_client_identifiers_for_client_id' );
convert_post_and_get_variable ( 'form_submitted' );
$ref_to_org_id += 0;
$page_title = 'Clients';
if ($_GET['clear_results'])
{
$message = '';
$message_type = 'ok';
$matching_clients_identifier_array = null;
}
if (!$cli_prof)
{
$cli_prof = new Client_profile();
}
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";
}
//MUST REMOVE OR ADD CLIENTS TO SESSION BEFORE CALLING SHOW REPORT OPTIONS...
if ( ereg ( '[0-9]', $_GET['remove_client_from_household_session'] ) )
{
$message = '';
$message_type = 'ok';
$cli_prof->remove_client_from_household_session ( $_GET['remove_client_from_household_session'] );
echo $message;
}
elseif ( ereg ( '[0-9]', $_GET['add_client_to_household_session'] ) )
{
$message = '';
$message_type = 'ok';
$cli_prof->add_client_to_household_session ( $_GET['add_client_to_household_session'] );
}
//Lookup Prep
if ( $form_submitted == 'relationship_change' )
{
$message = '';
$message_type = 'ok';
$cli_prof->edit_client_relationship_session ( $form_answer['rel'] );
}
//If no client info is loaded into the session, send them to the client id entry page
//...and no client identifiers are loaded into the system, take them to the the identifier options
if ( !$client_info )
{
$message = "No client forms are available because no client is defined in the View.";
$message_type = "ok";
$tag_values['{CLIENT PROFILE}'] = '<table class="generictable"><tr><td class="generictabletop">Clients in View</td></tr></table><table class="generictable"><tr><td class="smalltd">None</td></tr></table><br><i>To access a client form at least one client must be in view. You can add an existing client to the view from the lookup query results below or by adding a new client to the system.</i>';
$tag_values['{RELATIONSHIPS}'] = " ";
$tag_values["{REPORT_OPTIONS}"] = " ";
//header ( 'Location: '.$system_directory.'createclients.php?report_name=options_identifier&empty_form=yes' );
}
else
{
//Shows the client currently in view.
$profile = new Client_profile;
//echo "<br>Should be display_client_profile_table($client_info, 'Clients in View', $profile_table_type, $this_page, $page_id) "; //$form_submitted $form_status
$tag_values["{CLIENT PROFILE}"] = $profile->display_client_profile_table ($client_info, 'Clients in View', 'clients'); //, $formtype);
show_client_report_options();
}
//End Lookup Prep
//Client Lookup Form
if ( $form_answer )
{
$message = '';
$message_type = 'ok';
$id_quests = new Client_id;
$id_quests->pull_client_id_entry_questions_array ( '0', 'yes' );
$validated_iden_ans = new Questions_answers_validation ( $id_quests->questions, $id_quests->question_elements, $form_answer );
//Ensure all client names submitted for search are cased just as they are entered into the database.
//That is, first letter of first, middle, and last name are capetalized and rest is lowercase. This
//is done because search, queries are all case sensative on encrypted values. Note hardcoded 0!
if (strlen($validated_iden_ans->vetted_value["name_first0"])>0)
$validated_iden_ans->vetted_value["name_first0"] =
ucfirst(strtolower(trim($validated_iden_ans->vetted_value["name_first0"])));
if (strlen($validated_iden_ans->vetted_value["name_middle0"])>0)
$validated_iden_ans->vetted_value["name_middle0"] =
ucfirst(strtolower(trim($validated_iden_ans->vetted_value["name_middle0"])));
if (strlen($form_answer["name_last0"])>0)
$validated_iden_ans->vetted_value["name_last0"] =
ucfirst(strtolower(trim($validated_iden_ans->vetted_value["name_last0"])));
//$rel = new Relationships ( $client_info[0]['client_id'] );
$tag_values['{RELATIONSHIPS}'] = ' '; //$rel->display_other_related_clients_table();
//Display Lookup Form with submitted data
display_client_lookup_entry_form ( $validated_iden_ans->vetted_form_answer );
$clup = new Client_lookup;
$matching_clients_identifier_array = $clup->lookup_client_using_identifiers ( $id_quests->questions, $validated_iden_ans->vetted_value );
//echo 'matchin array<p>'; var_dump ( $matching_clients_identifier_array ); echo '<p>';
$_SESSION['matching_clients_identifier_arrayB'] = $matching_clients_identifier_array;
$tag_values['{MATCHING_CLIENTS}'] = display_client_identifiers_table ( $matching_clients_identifier_array, 'Clients matching query' );
$tag_values['{FORM_END}'] .= form_end ($button_label, 2);
//echo '<hr color=purple>';
}
else
{
//$rel = new Relationships ( $client_info[0]['client_id'] );
//$tag_values['{RELATIONSHIPS}'] = $rel->display_other_related_clients_table();
$tag_values['{RELATIONSHIPS}'] = " "; //we no longer display relationships on this page as it does not make sense...
//Display Lookup Form
display_client_lookup_entry_form ();
if ($matching_clients_identifier_array)
{
$tag_values['{MATCHING_CLIENTS}'] = display_client_identifiers_table ( $matching_clients_identifier_array, 'Clients matching query' );
$tag_values["{FORM_END}"] .= form_end ($button_label, 2);
}else{
//$tag_values["{FORM_END}"] .= display_hidden_form_values("results", 'FALSE');
$tag_values["{FORM_END}"] .= submit_button ( 'list', 'Return list of matching clients' );
}
$tag_values["{FORM_END}"] .= "</form>";
}
//End Client Lookup Form
/********************************************************************************************
* Name: show_client_report_options:
* Description: Return all report forms for client.
*
* Details and Notes:
*
* @param: Several global params
* @return: html written to global $tag_values
*
* History: Updated 1/17/03 by Jeff.
********************************************************************************************/
function show_client_report_options ()
{
GLOBAL $tag_values, $html_template, $page_id, $instructions, $user_id, $org_id, $client_info, $page_title, $message, $message_type, $this_page;
$page_id = "report_options";
$instructions = "Choose from a form below";
$report_type= "options_client";
$report_types = "client";
$report_list_array = pull_names_of_reports_user_can_create ( $user_id, $org_id, $report_types );
$formtype = 'client';
$final_html .= '<br><table cellpadding=0 cellspacing=0><tr><td colspan=3>Select a ' .$formtype. ' form below for the above clients.</td></tr>';
$final_html .= '<tr><td> </td><td> <table>';
if ( is_array ( $report_list_array ) )
{
foreach ( $report_list_array AS $current_report )
{
$final_html .= '<tr><td>
<a href="'.$system_directory.'report.php?report_type_id='.$current_report['report_type_id'].'&empty_form=yes">'.
$current_report['report_title'].'</a></td></tr>';
}
}
else
{
$final_html .= '<tr><td>You do not have permission to create any forms.</td></tr>';
}
$final_html .= '</td></tr></table></td><td> </td></tr></table>';
$tag_values["{REPORT_OPTIONS}"] = $final_html;
}
//The following are also in the client_lookup_class.inc
//Sharing_permissions_question class
//display_client_lookup_entry_form()
//display_client_identifiers_table()
//ensure client_info persists
$_SESSION['client_infoB'] = $client_info;
//Set template
$html_template = "report_options.html";
//Define the values for tags contained in the html template
$tag_values["{FORM_START}"] = form_start ($this_page);
$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);
?>