Exemplo n.º 1
0
/** import family information from csv version of the excel master database
 */
function import_family($last_name, $first_name, $dob, $address, $telephone, $family_size, $seniors, $adults, $children, $delivery, $dietary, $second_fourth_both, $wages, $unemployment, $wic, $welfare, $head_start, $afdc, $veterans_aid, $social_security, $ssi, $other, $fuel, $food_stamps, $cooking, $start, $comments, $name2, $dob2, $name3, $dob3, $name4, $dob4, $name5, $dob5, $name6, $dob6, $name7, $dob7, $name8, $dob8, $name9, $dob9, $name10, $dob10, $sep2009, $oct2009, $nov2009, $dec2009, $jan2010, $feb2010, $mar2010, $apr2010)
{
    $root = create_client(null, $first_name, $last_name, '0', convert_date($dob));
    $second = false;
    $fourth = false;
    if ($second_fourth_both == '2nd') {
        $second = true;
    } else {
        if ($second_fourth_both == '4th') {
            $fourth = true;
        } else {
            if ($second_fourth_both == 'Both') {
                $second = $fourth = true;
            }
        }
    }
    // Create Family
    $fid = create_family($root, $family_size, $address, $telephone, $fuel == 'Y', false, $delivery == 'Y', $dietary == 'Y', $second, $fourth, $cooking == 'Y', convert_date($start), $comments);
    // Import Family Members
    for ($i = 2; $i < 11; $i++) {
        $name_var = 'name' . $i;
        $dob_var = 'dob' . $i;
        $name = ${$name_var};
        $dob = ${$dob_var};
        if ($name == '') {
            break;
        }
        create_client($fid, $name, '', true, convert_date($dob));
    }
    // Add Family Financial Aids
    // $wages, $unemployment, $wic, $welfare, $head_start, $afdc, $veterans_aid, $social_security, $ssi, $other, $fuel, $food_stamps
    $aids = get_all_aids();
    $aidid = '-1';
    $amount = '0';
    foreach ($aids as $aid) {
        switch ($aid['name']) {
            case 'Wages':
                $amount = $wages;
                break;
            case 'Unemployment':
                $amount = $unemployment;
                break;
            case 'WIC':
                $amount = $wic;
                break;
            case 'Welfare':
                $amount = $welfare;
                break;
            case 'Head Start':
                $amount = $head_start;
                break;
            case 'AFDC':
                $amount = $afdc;
                break;
            case 'Veterans Aid':
                $amount = $veterans_aid;
                break;
            case 'Social Security':
                $amount = $social_security;
                break;
            case 'SSI':
                $amount = $ssi;
                break;
            case 'Other Amount':
                $amount = $other;
                break;
            case 'Fuel Assistance':
                $amount = $fuel;
                break;
            case 'Food Stamps':
                $amount = $food_stamps;
                break;
            default:
                $amount = '0';
                break;
        }
        if ($amount == 'Y') {
            $amount = "0";
        }
        if (is_numeric(trim($amount, "\$"))) {
            set_financial_aid($fid, $aid['aidid'], trim($amount, "\$"));
        }
    }
    $members = get_all_family_members($fid);
    $import_size = count($members) + 1;
    if ($import_size != $family_size) {
        echo "Missed family members for family " . $fid . " and name: " . $last_name . " imported " . $import_size . " and there were " . $family_size . "<br/>";
    }
}
Exemplo n.º 2
0
         $food_sources = get_all_food_sources();
         $id = new_dropoff_transaction();
         foreach ($food_sources as $food_source) {
             $field = clean_url($food_source['name']);
             $weight = post('foodsource-' . $field . '-weight');
             $price = post('foodsource-' . $field . '-price');
             new_dropoff_transaction_food_source($id, $food_source['sourceid'], $weight, $price);
         }
     }
     render_dropoffs();
     break;
 case 'new':
     if (post('did_submit') == 'yes') {
         $clientid = create_client(null, post('first_name'), post('last_name'), post('gender') == '1', post('dob'));
         if ($clientid > 0) {
             $familyid = create_family($clientid, post('bag'), post('address'), post('telephone'), post('fuel') == 'true', post('usda') == 'true', post('delivery') == 'true', post('dietary') == 'true', post('2nd') == 'true', post('4th') == 'true', post('cooking') == 'true', post('start'), post('comments'));
             if ($familyid > 0) {
                 redirect($g["abs_url"] . '/client/edit/' . $familyid);
             } else {
                 $client_framework_render['message'] = 'An error occurred.<br />';
             }
         } else {
             $client_framework_render['message'] = 'An error occurred.<br />';
         }
     }
     render_new();
     break;
 case 'edit':
     if (post('did_submit') == 'yes') {
         edit_client($client_command, post('first_name'), post('last_name'), post('gender') == '1', post('dob'));
         edit_family($client_command, post('bag'), post('active') == 'true', post('address'), post('telephone'), post('fuel') == 'true', post('usda') == 'true', post('delivery') == 'true', post('dietary') == 'true', post('2nd') == 'true', post('4th') == 'true', post('cooking') == 'true', post('start'), post('comments'));