\n"); $error_message = getLanguageText('ERRORMSG-ACCESS-DENIED'); include "form.messages.php"; return; } // // Build a database query based on the input data provided // if (!$_POST) return; extract($_POST); $PrimaryTable = "school_contact_list"; // // Define the default query to be used // $Parameters = ""; $EmailField = "contact_email"; $Recipients = array("contact_email","contact_name","school_name"); $Alignment = array("left","left","left"); $Category = "Hot Lunch Contacts Broadcast"; $Description = "Broadcast to Hot Lunch Application Contacts"; $Where = ""; // // Handle any parameters // if (isset($SelectedProvinces) && count($SelectedProvinces) > 0) { if (count($SelectedProvinces) > 1 || strlen($SelectedProvinces[0]) > 0) { $selectedProvinces = join(",",$SelectedProvinces); $Where .= "AND province IN ($selectedProvinces) "; } } if (isset($SelectedReseller) && count($SelectedReseller) > 0) { if (count($SelectedReseller) > 1 || strlen($SelectedReseller[0]) > 0) { $selectedReseller = join(",",$SelectedReseller); $Where .= "AND reseller IN ($selectedReseller) "; } } if (isset($SelectedSchools) && count($SelectedSchools) > 0) { if (count($SelectedSchools) > 1 || $SelectedSchools[0] != 0) { $selectedSchools = join(",",$SelectedSchools); $Where .= "AND school_num IN ($selectedSchools) "; } } if (isset($renewal_invoice_issued) && $renewal_invoice_issued != "") $Where .= "AND renewal_invoice_issued = '$renewal_invoice_issued' "; if (isset($renewal_invoice_paid) && $renewal_invoice_paid != "") $Where .= "AND renewal_invoice_paid = '$renewal_invoice_paid' "; if (isset($BalanceOwing) && $BalanceOwing == 'Y') { $Where .= "AND balance_owing > 0 "; } // Process updated selection list if (array_key_exists('sel',$_POST)) { if (is_array($_POST['sel'])) { $_POST['sel'] = join(",", $_POST['sel']); } $Where .= " and c.record_num IN ({$_POST['sel']})"; $Description .= " (custom recipient list)"; } // Set the set of fields from the schools table $schoolsFields = "timezone,url,expiry_date,system_configuration,system_access_code"; // Build the query $Query = "SELECT DISTINCT c.contact_name,c.contact_email,c.contact_phone,school_name,city,province,$schoolsFields,c.record_num " . "FROM school_contact_list AS c, schools AS s " . "WHERE c.contact_email is not null " . "AND c.contact_email != '' " . "AND school_num = s.record_num " . "AND c.active = 'Y' " . "AND s.status in ('Inactive') " . "AND s.reseller = 'hotlunch' " . $Where . "ORDER BY school_name,c.contact_email,c.contact_name"; // create attachment list if (array_key_exists('attachments',$_POST)) { if (is_array($_POST['attachments'])) { $attachments = $_POST['attachments'] = join(",", $_POST['attachments']); } } // // Determine how many emails will be sent // $results = db_query($Query); $num_rows = db_num_rows($results); // // Determine the number of schools // $num_schools = db_getVal("SELECT count(DISTINCT s.record_num) " . "FROM school_contact_list AS c, schools AS s " . "WHERE c.contact_email is not null " . "AND c.contact_email != '' " . "AND school_num = s.record_num " . "AND c.active = 'Y' " . "AND s.status in ('Inactive') " . $Where); ?>