<?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_access_levels = ':40:';
//$page_title = "Permissions";
//$page_id = "permissions";
////Header for every page that finds the include directory, connects to db, authenticates user access
include_once ( 'initialize_pointer.php' );
if ( !include_once ( $include_root.'authenticate.inc' ) ) { echo 'No Authentication'; exit; }
//include_once($include_root."client_profile_class.inc");
//include_once($include_root.'reports_class.inc');
include_once($include_root."Questions_into_array_class.inc");
include_once($include_root."questions_display.inc");
include_once($include_root."Questions_answers_validation_class.inc");
//include($include_root."question_set_validation_function.inc");
include_once($include_root."questions_into_tags_function.inc");
include_once($include_root."head.inc");
include_once($include_root."template_parser.inc");
include_once($include_root."page_elements_display.inc");
include_once($include_root."client_id_class.inc");
//include($include_root."client_report_class.inc");
include_once($include_root."insert_household_report_class.inc");
//include($include_root."insert_client_report_class.inc");
include_once($include_root."client_profile_class.inc");//
include_once($include_root.'client_lookup_class.inc');
include_once($include_root."reports_class.inc");//
include_once($include_root."report_date_questions_class.inc");
include_once($include_root."relationships_class.inc");
include_once($include_root."user_info_functions.inc");
//include($include_root."referrals_class.inc");
include_once($include_root."encryption_class.inc");
include_once($include_root."date_encrypted_functions.inc");
include_once($include_root."services_functions.inc");
$this_page = 'report.php'; //bugbug: this shouldn't be required
//<!--input type="hidden" name="form_submitted" value="client_chronic">
//<input type="hidden" name="report_name" value="client_chronic">
//<input type="hidden" name="form_status" value="submitted"--> //problematic, not in form...
convert_post_and_get_variable ( 'report_type_id' );
convert_post_and_get_variable ( 'referred_to_org' );
convert_post_and_get_variable ( 'form_status' );
convert_post_and_get_variable ( 'edit_report_id' );
//convert_post_and_get_variable ( 'report_name' );
convert_post_and_get_variable ('report_unit');
convert_post_and_get_variable ( 'form_submitted' );
//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');
//$ref_to_org_id += 0;
//$referred_to_org += 0;
//echo "report.php:<br>form_status:" . pretty_var_dump( $form_status )
//."<br>form_submitted: ". $form_submitted . "<br>report_type_id:". pretty_var_dump ( $report_type_id ) ."report_unit:". pretty_var_dump ( $report_unit ) ."report_name:". pretty_var_dump ( $report_name ) ."edit_report_id:". pretty_var_dump ( $edit_report_id );
//Pull out the report on unit for the first report in array
//bugbug todo: all of the following code is totally a hack and the real problem is that it seems the params being passed around from page to page
//are misnamed or param names are being changed or ? Hope to go through and make things consistant at some point...
if ( is_array ( $report_type_id ) )
{
foreach ( $report_type_id AS $cur_rpt_type_id )
{
$rpt_type_profile_array = pull_report_type_profile ( $cur_rpt_type_id );
break;
}
}
elseif ( $report_type_id )
{
$rpt_type_profile_array = pull_report_type_profile ( $report_type_id );
}
elseif ( $edit_report_id && $report_unit )
{
$rpt_type_profile_array = pull_report_type_profile ( $report_unit );
$report_type_id = $report_unit;
}
if (!$cli_prof)
{
//echo 'yo';
$cli_prof = new Client_profile();
}
//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';
$start_count_in_view = count($client_info);
$id_to_remove = $_GET['remove_client_from_household_session'];
if ($client_info[0]['client_id'] == $id_to_remove)
{
$message = 'By removing the lead client in view, all related clients were removed, and the next unrelated client in view becomes the lead.';
$message_type = 'ok';
}
$cli_prof->remove_client_from_household_session ( $id_to_remove, 'remove_all_in_household' );
}
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 = 'This change in relationship will not take effect until you submit a household form.';
$message_type = 'ok';
$cli_prof->edit_client_relationship_session ( $form_answer['rel'] );
//$form_status = 'relationship_change_submitted';
//echo '<hr color=blue>'.$form_status;
}
if (!$form_status)
$form_status = 'not_submitted';
if ( is_array ( $rpt_type_profile_array ) )
{
switch ( $rpt_type_profile_array['report_on_unit'] )
{
case 'household_service':
case 'household':
include_once ( $include_root.'report_household_form_class.inc' );
//first remove unrelated clients from view and present error message if this happens...
$new_client_info = array();
$unk_count = 0;
if (count($client_info)==0 && $edit_report_id < 1 )
{
echo 'Error. You cannot open a form without clients in view. <a href="index.php">Return</a>';
exit;
}
elseif ( $edit_report_id > 0 ) {
//We are editing a report (possibly from a email link), so load the related clients in
//Find the edit report id
if ( is_array ( $edit_report_id ) ) {
foreach ( $edit_report_id AS $cur_id ) {
//do nothing
}
}
else {
$cur_id = $edit_report_id;
}
$cli_prof->put_client_profiles_associated_with_household_report_into_client_info_session_variable ( $cur_id );
}
foreach ($client_info AS $key => $current_client)
{
if ($current_client['client_relationship_to_lead'] == 'unknown' || $current_client['client_relationship_to_lead'] == null)
{
//array_pop($key);
$unk_count++;
}
else
{
array_push($new_client_info, $current_client);
}
}
if ($unk_count>0)
{
$client_info = $new_client_info;
$_SESSION['client_infoB'] = $new_client_info;
$client_info = $new_client_info;
if ($unk_count>1)
$plural='s were';
else
$plural=' was';
$message = $unk_count.' unrelated client'.$plural.' removed from the View. Household forms can only be submitted for related clients.';
$message_type = 'error';
}
$rpt = new Report_household_form (
$report_type_id,
$group_id,
$org_id,
$user_id,
$referred_to_org,
$form_status,
$client_info,
$form_submitted,
$form_answer,
$edit_report_id
);
break;
case 'client_identifier':
case 'client_service':
case 'client':
include_once ( $include_root.'report_client_form_class.inc' );
/*echo "<br>Report_client_form ( $report_type_id,
$group_id,
$org_id,
$user_id,
$referred_to_org,
$form_status,
$client_info,
$form_answer,
$edit_report_id )<hr color=blue>";*/
$rpt = new Report_client_form (
$report_type_id,
$group_id,
$org_id,
$user_id,
$referred_to_org,
$form_status,
$client_info,
$form_answer,
$edit_report_id
);
break;
default:
echo '<p>No matching report for on unit type '.$rpt_type_profile_array['report_on_unit'].' found.'. '</p>'; exit;
}
}
?>