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


function get_active_services_array ()
{

    $sql = "SELECT * FROM services_taxonomy WHERE service_active = 1 order by service_display_term";
    
    $active_services = run_query_return_array ( $sql, "Pulling owned groups info" );
    
    foreach ( $active_services AS $cur_active_services ) {
        $active_services_array[$cur_active_services['service_id']] = $cur_active_services;
    }
    
    return $active_services_array;
}



function update_org_services ( $org_id, $services_array )
{
    
    $sql = "DELETE FROM services_provided_by_org WHERE org_id = ".$org_id;
    run_query($sql, "Delete current services for Org #".$org_id);
    
    foreach ( $services_array as $current_service )   {
        $sql = "INSERT INTO services_provided_by_org ( org_id, service_id ) VALUES ( ".$org_id.", ".$current_service.")";
        run_query($sql, "Inserting New Service ".$current_service." for Org #".$org_id);
    }
}



function get_services_by_org_id_array ( $org_id )
{
    GLOBAL $access_level;
    
    if ( $access_level == 40 ) {
        $org_sql = " AND services_provided_by_org.org_id = ".$org_id;
    }
    
    $sql = "SELECT * FROM services_taxonomy RIGHT JOIN services_provided_by_org ON services_provided_by_org.service_id = services_taxonomy.service_id WHERE services_taxonomy.service_active = 1".$org_sql." order by service_display_term";
    
    $active_org_services = run_query_return_array ( $sql, "Pulling owned groups info" );
    if ( $active_org_services ) {
        foreach ( $active_org_services AS $cur_active_org_services ) {
            $active_org_services_array[$cur_active_org_services['service_id']] = $cur_active_org_services;
        }
    }
    return $active_org_services_array;
}

?>
Return current item: Homeless Mangement Information System