Location: PHPKode > projects > Homeless Mangement Information System > hmis/include/referrals_class.inc
<?php
//*Client Data System, Copyright (C) 2000, 2001 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

class Referrals {

	function insert_referral ( $org_id_from, $org_id_to, $report_type_id, $report_id )	{
		GLOBAL $unix_date, $org_name, $user_id;
        
        //pull_other_organization_report_permissions ( $user_id, $user_org_id, $outside_org_id )
        $reports_ok_to_refer_array = pull_other_organization_report_permissions ( $user_id, $org_id_from, $org_id_to );
        //var_dump ( $reports_ok_to_refer_array );
        
        if ( strlen ( $reports_ok_to_refer_array[$report_type_id] ) > 0 )   {
        
            $sql = "
            INSERT INTO referrals (
		        hh_report_id, 
                referred_by_org_id, 
                referred_by_user_id, 
                referred_to_org_id, 
                date_created 
                )
	            VALUES ( 
                '".$report_id."', 
                '".$org_id_from."', 
                '".$user_id."', 
                '".$org_id_to."', 
                '".$unix_date."'
                )";
		    run_query ( $sql, 'Inserting referral' );
        }
        else {
            echo 'No permission to refer';
            exit;
        }	
	
	} 


    function build_referrals_to_us_table ($org_id)  {
        GLOBAL $system_directory, $org_name, $organization_term, $group_term;
        $sql = "SELECT * FROM referrals WHERE referred_to_org_id = '".$org_id."' ORDER BY date_created DESC";
        $referrals_array = run_query_return_array ($sql, "Pulling Referrals to us", "hh_report_id");
        
        //$ht = "<table>";
       // $ht = "<tr><td>";
        
        $ht .= "<table><tr><td class=\"generictabletop\" colspan=\"3\">Referrals to ".$org_name."</td></tr>";
		$ht .= "<tr><td class=\"genericsubtop\">From ".$organization_term."&nbsp;</td><td class=\"genericsubtop\">Referral Date</td><td class=\"genericsubtop\">Link</td></tr>";
        
        if ( is_array ($referrals_array) )  {
            foreach ( $referrals_array AS $cur_ref )    {

                $rpt_prof = pull_household_report_profile ( $cur_ref['hh_report_id'] );

                $user_info = pull_user_variables ($cur_ref["referred_by_user_id"]);

                $ht .= "<tr><td>".$user_info["org_name"]."</td><td>".safe_date("m-d-Y", $cur_ref["date_created"])."</td>
                <td><a href=\"".$system_directory."report.php?report_type_id[".$rpt_prof['report_type']."]=".$rpt_prof['report_type']."&edit_report_id=".$cur_ref["hh_report_id"]."&empty_form=yes\">
                Link to details</a></td></tr>";



            }
            
        
        }
        else    {
            $ht .= "<tr><td colspan=\"3\"><b>No referrals</b></td></tr>";
            
        }
        
        $ht .= "</table>";
    
        return $ht;
    
    
    }
    
    
    function build_referral_email_dropdown_html ( $org_id ) {
    
    
    
    }
    
    
    
    



}
?>
Return current item: Homeless Mangement Information System