Location: PHPKode > projects > Homeless Mangement Information System > hmis/include/report_household_form_class.inc
<?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

//TODO: Reports should simply be the parent class yes/no?  Same goes with a Report_client_form...
//TODO: Need to stop passing around arrays that don't need to be arrays and arrays with indexes bases on the values... 
//      This may have started in a way that made sense, but now it seems different indexes are used.  Maybe time to just use 0,1,2,...

class Report_household_form
{
    var $rpt_type_profile_array;
    var $group_id; 
    var $org_id; 
    var $user_id; 
    var $referred_to_org;
    var $referred_to_group;
    var $form_status;
    var $client_info;
    var $form_answer;
    var $edit_report_id;
    var $tag_values;
    var $vetted_form_answers;
    var	$date_quest;
    var	$date_html;
	var $report_type_id;
	var $form_submitted;
    var $pull_questions_for_org_id;
    var $pull_questions_for_group_id;
    var $rpt_author_org_name;
    var $rpt_author_name;
    var $rpt_timestamp;
    
    function 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 )
	{
    
        GLOBAL $user_name, $org_name, $unix_date;
        
	    //bugbug: I'm thoroughly confused as to what changed, why both arrays and scalers are passed to this page...
		if (is_array($report_type_id))
			$this->report_type_id = $report_type_id;
		else
			$this->report_type_id[$report_type_id] = $report_type_id;        
        
        
        $this->group_id = $group_id;
        $this->org_id = $org_id;
        $this->user_id = $user_id;
        $this->referred_to_org = $referred_to_org;
		$this->form_submitted = $form_submitted;
        $this->form_status = $form_status;
        $this->client_info = $client_info;
        $this->form_answer = $form_answer;
        
        //bugbug: I'm thoroughly confused as to what changed, why both arrays and scalers are passed to this page...
		if (is_array($edit_report_id))
		{
			$this->edit_report_id = $edit_report_id;
                        
		}
		else
		{
			if ($edit_report_id)
				$this->edit_report_id[$edit_report_id] = $edit_report_id;
			else
				$this->edit_report_id = null;
		}
        
        //If we editing a referral, find out the organization so we can pull the appropriate question attributes
        //echo "edit report id is ".$edit_report_id."<p>";
        if ( $this->edit_report_id > 0 )  {
        
            if ( is_array ( $this->edit_report_id ) )   {
                //Find last report id if an array
                foreach ( $this->edit_report_id AS $cur_rpt_id )   {
                    //do nothing
                }
                
            }
            else {
                $cur_rpt_id = $this->edit_report_id;
            }
        
            $sql = "
            SELECT referred_to_org_id, referred_by_org_id, referred_by_user_id
            FROM referrals
            WHERE hh_report_id = ".$cur_rpt_id."            
            
            ";
            
            $res = run_query ( $sql, 'Pulling org referred to' );
            
            if ( num_rows ( $res ) > 0 ) {
                
                $rpt_arr = fetch_array ( $res, 'Pull referral info', 0 );
                $this->referred_to_org = $rpt_arr['referred_to_org_id'];              
                                
            
            }
        
        }
        //Not editing so set as current user
        else {
            $this->rpt_author_org_name = $user_name;
            $this->rpt_author_name = $org_name;
            $this->rpt_timestamp = $unix_date;      
        }
        
        
        
        
        
        //Set the values needed to pull the appropriate form
        if ( $this->referred_to_org > 0 ) {
            $sql = "
            SELECT group_id FROM organizations WHERE org_id = ".$this->referred_to_org;
            
            $res = run_query ( $sql, 'Pulling group id' );
            $this->referred_to_group = fetch_result ( $res, 'Pulling group idb' );
            
            $this->pull_questions_for_org_id = $this->referred_to_org;
            $this->pull_questions_for_group_id = $this->referred_to_group;
            
            //Find the info on the report for header
            //$ref_user_info = pull_user_variables ($rpt_arr['referred_by_user_id']);
            
            //$this->rpt_author_org_name = $ref_user_info['org_name'];
            //$this->rpt_author_name = $ref_user_info['user_name_first'].' '.$ref_user_info['user_name_last'];
            
            
                        
        }
               
        else {
            $this->pull_questions_for_org_id = $this->org_id;
            $this->pull_questions_for_group_id = $this->group_id;
            
            //$this->rpt_author_org_name = $user_name;
            //$this->rpt_author_name = $org_name;
        
        }
		
	    
   /*    bugbug: moved to report.php 
        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");
*/		
        //Request for a empty referral form (NYI)
        if ( $this->form_status == 'not_submitted' && !$this->edit_report_id && $this->referred_to_org )
		{
            //echo '<p>Presenting Empty referral form </p>';
            $this->display_form_empty_referral ();
        }
        
        //Request for a totally empty form
        elseif ( $this->form_status == 'not_submitted' && !$this->edit_report_id )
		{
            //echo '<p>Presenting Empty form </p>';
            $this->display_form_empty ();
        }
        
        //Process a submitted blank form
        elseif ( $this->form_status == 'submitted' && !$this->edit_report_id )
		{
            //echo '<p>processing submitted form</p>';
            $this->process_submitted_new_form ();
        }
        
        //Display an existing report to edit 
        elseif ( $this->form_status == 'not_submitted' && $this->edit_report_id )
		{
            //echo '<p>display for edit</p>';
            $this->display_form_edit ();
        }
        
        //Process an edited report 
        elseif ( $this->form_status == 'submitted' && $this->edit_report_id )
		{
            //echo '<p>process edited form</p>';
            $this->process_submitted_new_form ();
        }
        
        //Process a delete request
        elseif ( $this->form_status == 'delete' && $this->edit_report_id )
		{
            //echo '<p>process edited form</p>';
            $this->process_delete_request ();
        }
        
        else
		{
            echo '<p>I do not know what to do with this request</p>';
            exit;
        }
		
    }



    function display_form ( )
	{
        GLOBAL $user_name, $org_name, $unix_date, $date_quest, $title_type, $instructions, $page_title;
        
        //echo '<br>report_household_form_class.display_form():'.pretty_var_dump ( $this->report_type_id );
        //$cur_rpt_type_id = $this->report_type_id['report_type_id'];
		$report_count = 0;
		$plural = '';
		
		//TODO: ADD CODE BACK TO ALLOW MULTIPLE REPORTS (ARRAY) TO BE DISPLAYED...
        foreach ( $this->report_type_id AS $cur_rpt_type_id )
		{
			
            //Find out if we have permission to work on this form
            if  ( !$this->edit_report_id )  { 
                $perms = per_group_report_type_id ( $this->user_id, $this->org_id, $cur_rpt_type_id );
                if ( $perms['read_rpt'] == 1 )  {
                    //do nothing
                }
                elseif ( $perms['create_rpt'] == 1 )    {
                    //do nothing
                }
                else {
                 echo 'You cannot view this report'; exit;
                }
                
            }
            $report_count++;
            //echo "<br>Cur report type id is ".$cur_rpt_type_id."<p>";
			//echo pretty_var_dump($cur_rpt_type_id);
            $rpt_type_profile = pull_report_type_profile ( $cur_rpt_type_id );
                        
            $pull_questions = 
                new Questions_into_array ( 
                    $rpt_type_profile['report_type_id'], 
                    40, 
                    $this->pull_questions_for_org_id, 
                    $this->pull_questions_for_group_id,
                    'display', 
                    $rpt_type_profile['report_type_id'].'__'  );
			
            $page_title = $rpt_type_profile['report_title'].' form';
            
            $page_id = $rpt_type_profile['report_type_id'];
            
            $this->tag_values['{FORM_END}'] .= display_hidden_form_values ( 
			                                          'report_type_id['.$rpt_type_profile['report_type_id'].']', 
													  $rpt_type_profile['report_type_id']    );
            
			
            
            
            
            //Modify title if we are making a referral
            if ( $this->referred_to_org > 0 )   {
                
                $sqly = "SELECT org_name FROM organizations WHERE org_id = ".$this->pull_questions_for_org_id;
			    
                $org_name_result = run_query ( $sqly, 'Org Name Pull' );
			    $report_referral_org_name = fetch_result ( $org_name_result, 'Org name pull' );
                
                $referral_mod_a = ' refferal';
                $referral_mod_b = ' to '.$report_referral_org_name;
                
                
                
            }
            
            
            //Modify the title to tell user if they are editing the report
			if ($report_count==1)
			{
			  if ( $this->edit_report_id )
			  {
	            $working_title = "Edit ".$rpt_type_profile['report_title'].$referral_mod_a." form".$referral_mod_b;
	            $instructions = "Edit this household's ".$rpt_type_profile['report_title'].$referral_mod_a." form".$referral_mod_b;
	          }
	          else
		      {
	            $working_title = "Submit new ".$rpt_type_profile['report_title'].$referral_mod_a." form".$referral_mod_b;
	            $instructions = "Submit a new ".$rpt_type_profile['report_title'].$referral_mod_a." form for this household".$referral_mod_b;
	          }
			}
			elseif ($report_count>1)
			{
				$plural="s";
			}
                        			
			//Get Dates
            if ( $rpt_type_profile['report_on_timeperiod'] != 'no' && !$date_quest)
            {
                $date_quest = new Report_date_questions ( '', '', $rpt_type_profile['report_on_timeperiod'] );
                $this->date_html = $date_quest->build_report_date_table ($valid_date_form_answers);
	        }
			//End Get Dates
            
            $reports = new Reports;
            
            $this->tag_values['{HOUSEHOLD_REPORT}'] .= 
			    $reports->display_report_profile (
                	$rpt_type_profile['report_title'], 
                	$this->rpt_author_name, 
                	$this->rpt_author_org_name, 
                	$this->rpt_timestamp  );
			
			//bugbug; I think this is all junk, tk 3-18-2004
            ////if (is_array($this->edit_report_id))
			////	$edit_rep_ids_vals = array_values($this->edit_report_id);
			////else
			////	$edit_rep_ids_vals[0] = null;
			
            
            //$perms = report_permissions_household ( $edit_rep_ids_vals[0], $this->org_id, $this->user_id );
			//echo "report_permissions_household ( $edit_rep_ids_vals[0], $this->org_id, $this->user_id )<br>";
			//echo pretty_var_dump($perms);
			
            $this->tag_values['{HOUSEHOLD_REPORT}'] .= 
                $reports->build_household_report ( 
                	$pull_questions->questions,
                	$pull_questions->question_elements,
                	$this->vetted_form_answers[$rpt_type_profile['report_type_id']],
                	$this->date_html,
                	$perms['report_sharing_permission']);
				
			//echo "<hr color=black>".pretty_var_dump($this->tag_values['{HOUSEHOLD_REPORT}']);
        }
		if ($report_count>0) $page_title = $working_title.$plural.".";
    }






    function display_form_empty ()
	{
        GLOBAL $instructions, $date_quest;
		
        //$instructions = 'Submit a new household report by entering information below. ';
                
        
        $this->display_form ();
        
        $this->tag_values['{FORM_END}'] .= display_hidden_form_values ( 'form_status', 'submitted' );
        $this->tag_values['{FORM_END}'] .= form_end ( 'Click here to submit new household form', 1 );
		
		//the following is now rolled up into the "{HOUSEHOLD_REPORT}" tag for some reason so just need to set 
		//$this->tag_values["{REPORT_PROFILE}"] to a space ' ' in commom_form_elements ().
		/*GLOBAL $org_name, $unix_date, $user_name;
		$reports = new Reports;
		$this->rpt_type_profile_array = pull_report_type_profile( $this->report_type_id );
		$this->tag_values["{REPORT_PROFILE}"] = $reports->display_report_profile (
		                                      $this->rpt_type_profile_array["report_title"], 
											  $user_name,
                                              $org_name, 
											  $unix_date);*/
	    
        $this->commom_form_elements ();
    }



    function display_form_empty_referral ()
	{
        GLOBAL $instructions, $date_quest;
       
        //$instructions .= 'Submit a new referral report by entering information below. ';
        
        $this->display_form ();
        
        $this->tag_values['{FORM_END}'] .= display_hidden_form_values ( 'referred_to_org', $this->referred_to_org );
        $this->tag_values['{FORM_END}'] .= display_hidden_form_values ( 'form_status', 'submitted' );
        $this->tag_values['{FORM_END}'] .= form_end ( 'Click here to submit new household form', 1 );
        $this->commom_form_elements ();
    }



    function display_form_with_errors ()
	{
        GLOBAL $instructions, $date_quest;
        
        $this->display_form ();
		
		//add to instructions with new message.
        $instructions .= ' Correct errors below. ';
        
		$this->tag_values['{FORM_END}'] .= display_hidden_form_values ( 'form_status', 'submitted' );
        $this->tag_values['{FORM_END}'] .= form_end ( 'Click here to submit corrected household form', 1 );
        $this->commom_form_elements ();
    }




    function display_form_edit ()
	{
        GLOBAL $instructions, $date_quest, $question_validation_error;
		
		//echo '<br>display_form_edit():'.pretty_var_dump($this->edit_report_id);
        
        if ( is_array ( $this->edit_report_id ) )
		{
			//echo "<hr color=red>";
            foreach ( $this->edit_report_id AS $cur_edit_rpt_id )
			{
                $perms = report_permissions_household ( $cur_edit_rpt_id, $this->org_id, $this->user_id );
                //echo "perms".pretty_var_dump ($perms);
                if ( $perms['read_rpt'] == 1 || $perms['edit_rpt'] == 1 )
				{
                    //Pull the report type id of the report using the report id //bugbug: constructor is never called???
                    $rpt_class = new Reports;
                    $rpt_prof = $rpt_class->pull_existing_report_profile ( $cur_edit_rpt_id );
                    
                    $this->rpt_author_org_name = $rpt_prof['org_name'];
                    $this->rpt_author_name = $rpt_prof['user_name_first'].' '.$rpt_prof['user_name_last']; 
                    $this->rpt_timestamp = $rpt_prof['report_timestamp'];
                    
                    //$rpt_prof = pull_household_report_profile ( $cur_edit_rpt_id );
                    $rpt_type_profile = pull_report_type_profile ( $rpt_prof['report_type'] );
					//echo "rpt_prof:".pretty_var_dump ( $rpt_prof );
                    //echo "this->report_type_id[".$rpt_prof['report_type']."]";
                    $this->report_type_id[$rpt_prof['report_type']] = $rpt_prof['report_type'];
                    $this->tag_values['{FORM_END}'] .= display_hidden_form_values ( 
					                                       'edit_report_id['.$rpt_prof['report_type'].']',
														   $cur_edit_rpt_id );
                    
                    $pull_questions = 
                        new Questions_into_array ( 
                            $rpt_prof['report_type'], 
                            40, 
                            $this->pull_questions_for_org_id, 
                            $this->pull_questions_for_group_id,
                            'display', 
                            $rpt_prof['report_type'].'__'
                        );
                    
                    $hh_rpt = new Reports;  
                    //var_dump ( $pull_questions->questions );
                    
                    $this->vetted_form_answers[$rpt_prof['report_type']] = 
                        $hh_rpt->pull_existing_report_answers ( 
                            $cur_edit_rpt_id, 
							$pull_questions->questions, 
							$pull_questions->question_elements, 
							$rpt_prof['report_type'].'__' 
                        );

                    if ( $rpt_type_profile["report_on_timeperiod"] != "no" )
			        {
                        $date_quest = new Report_date_questions( '', '', $rpt_type_profile['report_on_timeperiod'] );
                        $pulled_dates = $date_quest->pull_existing_report_dates ($cur_edit_rpt_id);
                        $this->date_html = $date_quest->build_report_date_table ($pulled_dates);
                    }

                    $end .= "<p/>".list_previous_versions_of_hh_report ( $cur_edit_rpt_id );
                    $end .= "<a href=\"#\" onclick=\"javascript:confirm_action('Are you sure you want to delete this form?','".
                                 $this_page."?form_status=delete&report_type_id=".
					             $rpt_prof['report_type']."&edit_report_id=".
					              $cur_edit_rpt_id."');\">Click here to DELETE this form</a>";
                }
                else
				{
                    echo '<p>No permission to read this household formppp</p>';
                }
				//echo "<hr color=red>";
            
            }
        }
        else
		{
            echo '<p>No reports to edit</p>';
        }
        
        $this->display_form ( );
		$instructions .= ' Edit report by changing values below. ';
        
        $this->tag_values['{FORM_END}'] .= display_hidden_form_values ( 'form_status', 'submitted' );
        
        $this->tag_values['{FORM_END}'] .= form_end ( 'Click here to submit edited household form', 1 );
		if ( !$question_validation_error )
			$this->tag_values['{FORM_END}'] .= edit_button (1);
        $this->tag_values['{FORM_END}'] .= $end;
        
        $this->commom_form_elements ();
    }






    function process_submitted_new_form ()
	{
        GLOBAL $question_validation_error, $date_quest;
        
        foreach ( $this->report_type_id AS $cur_rpt_type_id )
		{
            $rpt_type_profile = pull_report_type_profile ( $cur_rpt_type_id );
        
            $pull_questions[$rpt_type_profile['report_type_id']] = 
                new Questions_into_array ( 
                    $rpt_type_profile['report_type_id'], 
                    40, 
                    $this->pull_questions_for_org_id, 
                    $this->pull_questions_for_group_id,
                    'display', 
                    $rpt_type_profile['report_type_id'].'__'
                );
            
            //Validate the answers against the questions attributes pulled into an array above
            $validation[$rpt_type_profile['report_type_id']] = new Questions_answers_validation ( 
                $pull_questions[$rpt_type_profile['report_type_id']]->questions, 
                $pull_questions[$rpt_type_profile['report_type_id']]->question_elements,
                $this->form_answer
            );
            $this->vetted_form_answers[$rpt_type_profile['report_type_id']] =
                         $validation[$rpt_type_profile['report_type_id']]->vetted_form_answer;
            
            if ( $rpt_type_profile['report_on_timeperiod'] != 'no' )
			{
                $date_quest = new Report_date_questions ( '', '', $rpt_type_profile["report_on_timeperiod"] );
                $validation_date = new Questions_answers_validation(
                    $date_quest->questions,
                    $date_quest->question_elements,
                    $this->form_answer
                );
                $date_quest->validate_dates_exist ( true );
            }
            
            
            $hh_rpt = new Reports;
            $share_answer = $hh_rpt->validate_household_share_answer ( $this->form_answer ); 
            
            //$relationships->process_added_clients_checkboxes ($form_answer_added_client);
        }
        
        if ( $this->rpt_type_profile_array["report_on_timeperiod"] != "no" )
        {
            if ($date_quest->existing_report_dates)
            {
                $valid_date_form_answers = $date_quest->existing_report_dates;
            }
            else
            {
                $valid_date_form_answers = $validation_date->vetted_form_answer;
            }
            $this->date_html = $date_quest->build_report_date_table ($valid_date_form_answers);
        }
        
        //Check that this is not a form that has aleady been submitted
        duplicate_form_submission_check ( $_POST['fsig'] );
        
        if ( !$question_validation_error )
		{
            foreach ( $this->report_type_id AS $cur_rpt_type_id )
			{
            //If no form error, and a fresh form was not requested, insert the data, give a OK message, and go to next page/form
            
                $insert_answers = new Insert_household_report;
                
                if ( $rpt_type_profile["report_on_timeperiod"] != "no" )
                {
                    $insert_dates = $date_quest->translate_report_dates_to_unix_time($validation_date->vetted_value);
                }
                
                //Strip out the report type from the begining of the vetted values (i.e., 'household_intake__109' becomes '109')
                foreach ( $pull_questions[$cur_rpt_type_id]->questions AS $cur_quest )
				{
                    $real_question_id = str_replace ( $rpt_type_profile['report_type_id'].'__', '', $cur_quest['question_id'] );
                    //echo "the real id is: ".$real_question_id."<p>";
                    $question_holder[$real_question_id] = $cur_quest;
                    $question_holder[$real_question_id]['question_id'] = $real_question_id;
                    $answer_holder[$real_question_id] = 
                                $validation[$rpt_type_profile['report_type_id']]->vetted_value[$rpt_type_profile['report_type_id'].'__'.$real_question_id];
                }
                
                
                if ( $this->referred_to_org )   {
                    $rpt_owner_org_id = $this->referred_to_org;
                }
                else {
                    $rpt_owner_org_id = $this->org_id;
                }
                
                
                $new_report_id = $insert_answers->insert_report_answers ( 
                    $cur_rpt_type_id, 
                    $this->client_info,
                    $question_holder, 
                    $answer_holder, 
                    $rpt_owner_org_id, 
                    $share_answer, 
                    $this->edit_report_id[$cur_rpt_type_id], 
                    $insert_dates 
                    );
                
                unset ( $question_holder );
                unset ( $answer_holder );
                
                //If a referral, record referral
                if ( $this->referred_to_org )
				{
                    //echo 'Processing referral<p>';
                    include_once($include_root.'referrals_class.inc');
                    $ref = new Referrals();
                    
                    $ref->insert_referral ( $this->org_id, $this->referred_to_org, $cur_rpt_type_id, $new_report_id );
                    $notify_users_array = per_group_report_type_id_notification ( $this->referred_to_org, $cur_rpt_type_id, 'create' );
                    //echo "Here are the users<p/>";
                    //var_dump ( $notify_users_array );
                    
                    include_once($include_root.'email_class.inc');
                    $email = new Email();
                    $email->email_notification_of_report_to_users ( $this->user_id, $notify_users_array, 'HMIS Referral',
                    $rpt_type_profile['report_title'],
                    $cur_rpt_type_id, $new_report_id );
                }
                
                //If we are editing a report, send the new report id into the direct to page function
                //if ( $edit_rpt || $report_type_profile['report_that_follows'] == 'none' )    {
                //    $return_to_this_report = $new_report_id;
                //}
                
                //Note the report we have inserted for later editing
                ////$tag_values['{FORM_END}'] .= display_hidden_form_values ( 'edit_report_id['.$new_report_id.']', $new_report_id );
                
                $this->edit_report_id[$rpt_type_profile['report_type_id']] = $new_report_id;
                $this->tag_values['{FORM_END}'] .= display_hidden_form_values ( 'edit_report_id['.$cur_rpt_type_id.']', $new_report_id );
                
                
                ////direct_to_page ( $report_type_profile['report_type_id'], 'yes_empty_form', 'yes_following_page',
                //// $return_to_this_report, $report_unit );
            }
            
            //echo 'submitted_form_ok';
            $this->display_form_edit ();
        }
        
        //There is an error, or fresh form indicator, return report entry form
        else
		{
            if ( is_array ( $this->edit_report_id ) )
			{
                foreach ( $this->edit_report_id AS $rpt_type => $cur_edit_rpt_id )
				{
                    $this->tag_values['{FORM_END}'] .= display_hidden_form_values ( 'edit_report_id['.$rpt_type.']', $cur_edit_rpt_id );
                }
            }
            if ( $this->referred_to_org > 0 )
			{
                $this->tag_values['{FORM_END}'] .= display_hidden_form_values ( 'referred_to_org', $this->referred_to_org );
            }
            $this->display_form_with_errors ();
        }
    
    }

    function commom_form_elements ()
	{
        GLOBAL $client_info, $head_page_specific, $head_dynamic_style, $org_name, $unix_date, $user_name;
        
		//Client Profile table (the view) is only displayed on household forms
        $profile = new Client_profile;
		
		if ($this->edit_report_id && $this->form_submitted != 'relationship_change')
		{
			$this->client_info = $profile->enforce_h_view_rules($this->edit_report_id);
		}
		
		$client_info = $this->client_info;  //is this needed?
        $this->tag_values['{CLIENT PROFILE}'] = $profile->display_client_profile_table ( $this->client_info, '', 'household_forms', $this->edit_report_id, $this->report_type_id, $this->form_status );
        
		//$client_info = $this->client_info;
		//all related clients are added to view so no need for related table
        //$relationships = new Relationships ( $this->client_info['0']['client_id']);
        //$this->tag_values['{RELATIONSHIPS}'] = $relationships->display_other_related_clients_table ();
        
        $reports = new Reports;
        $this->tag_values['{EXISTING REPORTS}'] = 
            $reports->display_household_reports_table ( $this->client_info[0]['client_id'], $this->org_id );
        
        $this->tag_values["{FORM_START}"] = form_start ();
        
        $this->tag_values["{PAGE TITLE}"] = page_title_table();
        $this->tag_values["{MENU}"] = menu();
        $this->tag_values["{HEAD}"] = head ( $page_title, $head_page_specific, $head_dynamic_style );
        $this->tag_values["{FOOTER}"] = footer();
        
		//NOTE: The reason not to use REPORT_PROFILE seperately is that more than one report is appended to 
		//      "{HOUSEHOLD_REPORT}" and so we include the report profile header inline...
		$this->tag_values["{REPORT_PROFILE}"] = ' ';
		
        $html_template = 'household_report_forms.html';
        template_parser ( $html_template, $this->tag_values );
    }



    function process_delete_request ( )
    {
        $delete_report = new Insert_household_report;
        foreach ( $this->edit_report_id AS $cur_del )
		{
            $delete_report->delete_household_report ( $cur_del );
        }
        
        $this->display_form_edit ();
    }

} //END class
?>
Return current item: Homeless Mangement Information System