/** 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/>"; } }
} } 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')); clear_financial_aids($client_command); $aids = get_all_financial_aids(); foreach ($aids as $aid) { $field = clean_url($aid['name']); $check = post('aid-' . $field); $amount = post('aid-' . $field . '-text'); if ($check == 'true') { set_financial_aid($client_command, $aid['aidid'], $amount); } } } if (isset($client_command)) { render_edit($client_command); } else { redirect($g["abs_url"] . '/error/invalid-page'); } break; case 'render': if (isset($client_command) && in_array($client_command, $render_commands)) { switch ($client_command) { case 'family_members': if (isset($action_command)) { render_family_members($action_command);