= '07') { $school['expiry_date'] = date("Y-m-d",time() + 60 * 60 * 24 * 31); } // // Handle reseller overrides // if ($reseller != "hotlunch") { $results = db_query("SELECT * FROM resellers WHERE reseller_code = '$reseller'"); if (db_num_rows($results)) { $overrides = db_fetch_assoc($results); $reseller_source_school_num = $overrides['source_school_num']; $src_school = array(); if ($reseller_source_school_num > 0) { echo("Reseller Source School: $reseller_source_school_num\n"); $results = db_query("SELECT * FROM schools WHERE record_num = $reseller_source_school_num"); if (db_num_rows($results)) $src_school = db_fetch_assoc($results); // Get any additional pages and copy them db_query("DELETE FROM formatted_content WHERE school_num = $school_num && content_type = 'A'"); $results = db_query("SELECT * FROM formatted_content WHERE school_num = $reseller_source_school_num && content_type = 'A'"); if (db_num_rows($results)) { $formatted_content = new Table('formatted_content'); $date_added = date("Y-m-d",time()); while ($additional = db_fetch_array($results)) { $content_id = $additional['content_id']; $content_type = $additional['content_type']; $sequence = $additional['sequence']; $content = $additional['content']; $query = $formatted_content->BuildInsert(); db_query($query); } } } $Fields = array( "bill_to_address", "bill_to_city", "bill_to_province", "bill_to_country", "bill_to_postal", "bill_to_phone", "registrants_are", "participants_are", "participant_grouping", "group_leaders", "template", "bg_color", "colour_scheme", "background", "menu_color", "menu_text_color", "menu_hover", "hover_text_color", "data_odd", "data_odd_text", "data_even", "data_even_text", "menu_dates_on_holidays", "system_configuration", "email_system", "other_modules", "event_calendar", "classified_ads", "photo_gallery", "use_access_code", "login_form_location", "enable_parent_registration", "registrations_permitted", "enable_customers", "customer_address", "customer_phone", "customer_email", "allow_parent_login", "allow_guest_login", "enable_participant_registration", "enable_customer_registration", "registration_userid", "registration_second_parent", "registration_phone", "registration_email", "registration_daytime_phone", "registration_cell_phone", "registration_address", "additional_registration_data_field1", "additional_registration_data_field2", "email_list_permission", "email_list_text", "collect_student_birthdate", "collect_student_age", "collect_student_sex", "collect_student_grade", "collect_student_number", "collect_permission", "permission_prompt", "permission_description", "p_display_teachers", "p_display_program", "p_display_grade", "p_display_division", "p_display_description", "i_display_teachers", "i_display_program", "i_display_grade", "i_display_division", "i_display_description", "c_display_name", "c_display_home_phone", "c_display_work_phone", "c_display_cell_phone", "c_display_home_email", "student_button_text", "student_class_text", "division_class_num_text", "user_defined_values", "user_defined_title", "user_defined_values2", "user_defined_title2", "class_sort", "max_schedules", "menu_dates_on_holidays", "max_teachers_per_class", "staff_meals_to_classroom", "display_staff_list", "display_class_lists", "display_pac_info", "allow_userid_change", "display_user_account_balance", "minimum_display_balance", "maximum_order_balance", "balance_calculation_days_ago", "allow_ordering_with_balance_owing", "previous_balances_post", "previous_balances_post_message", "no_ordering_message", "verified_only_class_list", "allow_edit_of_paid_orders", "allow_edit_of_complimentary_orders", "order_entered_message", "schedule_sort", "special_item_prices", "taxable_items", "display_bc_food_guidelines", "label_print_school_name", "enable_volunteer_signup", "enable_volunteer_management", "include_volunteer_details", "max_volunteers", "default_volunteer_message", "group_a_color", "group_b_color", "group_c_color", "group_d_color", "group_e_color", "group_f_color", "group_g_color", "group_h_color", "group_i_color", "group_j_color", "group_k_color", "group_l_color", "group_m_color", "display_group_colors", "display_group_letters", "implement_meal_locations", "logo_image", "logo_url", "receipt_image", "receipt_title", "display_staff_list", "display_class_lists", "display_pac_info", "menu_item_font_size", "menu_item_color", "check_register_sort", "display_user_account_balance", "minimum_display_balance", "maximum_order_balance", "balance_calculation_days_ago", "allow_ordering_with_balance_owing", "previous_balances_post", "previous_balances_post_message", "exact_enabled", "exact_code", "exact_currency", "exact_button_text", "display_remittance_button", "remittance_button_text", "accept_check", "accept_cash", "display_remittance_msg_with_button", "remittance_form_fee", "display_print_order_button", "calculate_supplier_costs", "supplier_costs_decimals", "default_student_status", "default_order_status", "default_event_status", "num_reminder_events", "public_event_calendar", "default_classified_status", "classified_duration", "additional_pages_title", "support_email", "reply_email", "reply_description", "email_title", "email_footer", "email_reminder_optional", "email_reminder_title", "email_reminder_day", "volunteer_reminder_title", "volunteer_reminder_day" ); for ($i = 0; $i < count($Fields); $i++) { $field = $Fields[$i]; if (in_array($field,$overrides) && strlen($overrides[$field])) { if ($overrides[$field] == "none") $school[$field] = ''; else $school[$field] = $overrides[$field]; } if (is_array($src_school) && array_key_exists($field,$src_school)) { $school[$field] = $src_school[$field]; echo("$field: " . $src_school[$field] . "\n"); } } } $school['expiry_date'] = date("Y-07-31",time() + 60 * 60 * 24 * 200); } extract($school); echo($order_entered_message . "\n\n"); echo("$expiry_date\n"); echo("$url\n"); $record_num = $school_num; if ($school['status'] != 'Linked') { $document_path = sprintf("%08d",$record_num); mkdir("files/$document_path",0777); $subdirs = array("attachments","documents","galleries","image","product_images","orders","admin","admin/lists","admin/aliases",".thumbs"); for ($i = 0; $i < count($subdirs); $i++) { $sdir = $subdirs[$i]; mkdir("files/$document_path/$sdir",0777); } // Copy images from source if required if (isset($reseller_source_school_num) && $reseller_source_school_num > 0) { $source_path = sprintf("%08d",$reseller_source_school_num); for ($i = 0; $i < count($subdirs); $i++) { $sdir = $subdirs[$i]; $dir = opendir("files/$source_path/$sdir"); while ($file = readdir($dir)) { if ($file == ".") continue; if ($file == "..") continue; copy("files/$source_path/$sdir/$file","files/$document_path/$sdir/$file"); } closedir($dir); } } } $schools = new Table("schools"); $query = $schools->BuildUpdate(); db_query($query); // Check if there is an admin user if ($school['status'] != 'Linked') { $query = "select * from users where school_num = $base_school_num and userid = 'admin'"; $results = db_query($query); if (db_num_rows($results) == 0) { // Create an admin user $userid = "admin"; $password = "admin"; $type = "System Administrator"; $status = "Active"; $first_name = "Administrator"; $users = new Table("users"); $query = $users->BuildInsert(); db_query($query); } // // Insert staff categories $staff_categories = array('Principal','Vice Principal','Administration','Teacher','Support Staff','SEA','Librarian','Other Staff'); for ($i = 0; $i < count($staff_categories); $i++) { $scat = $staff_categories[$i]; $seq = $i + 1; // Check if this category exists $query = "select * from staff_categories " . "where school_num = $school_num " . "and category_title = '$scat'"; $results = db_query($query); if (db_num_rows($results) == 0) { $query = "insert into staff_categories (school_num,category_title,sequence) " . "values ($school_num,'$scat',$seq)"; db_query($query); if ($scat == 'Teacher') { $dnum = db_insert_id(); db_query("update schools set default_staff_category = $dnum where record_num = $school_num"); } } } } // Setup default content $formatted_content = new Table("formatted_content"); // Create login screen message $content_type = 'C'; $content_id = "Login Page"; $query = "delete from formatted_content where school_num = $school_num and content_id = '$content_id'"; db_query($query); $content = ""; if (isset($reseller_source_school_num) && $reseller_source_school_num > 0) { $content = db_getVal("SELECT content FROM formatted_content WHERE school_num = $reseller_source_school_num AND content_id = '$content_id'"); } if (strlen($content) == 0) { switch ($siteType) { case 'hotlunch': $content = "

Welcome to the $pac_name and Lunch web site. On this site parents will be " . "able to place lunch orders for their children.

\n" . "

We believe that by involving and informing parents we will have a more supportive and effective school " . "environment for our children. It is up to us to work together to ensure our children have the best " . "possible school experience.

\n"; break; case 'fundraising': $content = "

Welcome to the $pac_name fund raising web site. On this site parents will be " . "place fund raising orders for our $orgType.

\n"; break; case 'schoolfees': $content = "

Welcome to the $pac_name school fees web site. On this site parents will be able to pay school fees and " . "register children for fieldtrips.

\n"; break; case 'registration': $content = "

Welcome to the $pac_name registration web site.

\n"; break; } } $query = $formatted_content->BuildInsert(); db_query($query); // Create login screen message $content_type = 'C'; $content_id = "Welcome Page"; $query = "delete from formatted_content where school_num = $school_num and content_id = '$content_id'"; db_query($query); $content = ""; if (isset($reseller_source_school_num) && $reseller_source_school_num > 0) { $content = db_getVal("SELECT content FROM formatted_content WHERE school_num = $reseller_source_school_num AND content_id = '$content_id'"); } if (strlen($content) == 0) { switch ($siteType) { case 'hotlunch': $content = "

Welcome

\n" . "

Welcome to the lunch on-line system. This application is meant to " . "facilitate the ordering and management of school lunch orders for both " . "parents and the $pac_name. Please feel free to contact us with any suggestions " . "or problems you have with the system.

\n"; break; case 'fundraising': $content = "

Welcome

\n" . "

Welcome to the $pac_name fund raising web site. On this site parents will be " . "place fund raising orders for our $orgType.

\n"; break; case 'schoolfees': $content = "

Welcome

\n" . "

Welcome to the $pac_name school fees web site. On this site parents will be able to pay school fees and " . "register children for fieldtrips.

\n"; break; case 'registration': $content = "

Welcome

\n" . "

Welcome to the $pac_name registration web site.

\n"; break; } } $query = $formatted_content->BuildInsert(); db_query($query); if ($school['status'] != 'Linked') { if ($reseller == 'hotlunch') { // Setup page content entries if ($siteType == 'hotlunch') { $pages = array('Council Information'); for ($i = 0; $i < count($pages); $i++) { $page = $pages[$i]; // Check if this page has already been created $query = "select * from formatted_content " . "where school_num = $school_num " . "and content_type = 'C' " . "and content_id = '$page'"; $results = db_query($query); if (db_num_rows($results) == 0) { $query = "insert into formatted_content (school_num,content_id,content_type) " . "values ($school_num,'$page','C')"; db_query($query); } } } // Create no access to class list message if ($siteType == 'hotlunch') { $content_type = 'C'; $content_id = "Access to Class List Denied"; $query = "select * from formatted_content where school_num = $school_num and content_id = '$content_id'"; $results = db_query($query); if (db_num_rows($results) == 0) { $content = "

You have accessed the contact list for your child's class, but your child " . "has not yet been verified in the system. In order to protect our children " . "we only allow access to the class lists once your child has been verified. " . "As parents we are sure you understand our caution.

\n" . "

Please bear with us as we are processing the registrations and verifying " . "the students as fast as possible.

\n" . "

$pac_name

"; $query = $formatted_content->BuildInsert(); db_query($query); } } // Create the default events email message if ($siteType == 'hotlunch') { $content_type = 'Events'; $content_id = db_escape_string("$pac_name Event Calendar"); $query = "select * from formatted_content where school_num = $school_num and content_type = '$content_type'"; $results = db_query($query); if (db_num_rows($results) == 0) { $content_id = "$pac_name Event Calendar"; $content = "

Dear Parent,

\n

The following are the upcoming school and community events from the on-line event calendar on " . "our $pac_name web site. We invite you to visit the site and post any child and family friendly events to our event calendar " . "to share with the other parents at $school_name.

\n

We will send a list of events to all parents monthly.

\n
\n"; $query = $formatted_content->BuildInsert(); db_query($query); } } // Create the reminder email if ($siteType == 'hotlunch') { $content_type = 'Reminder'; $content_id = db_escape_string("$pac_name Web Password Reminder"); $query = "select * from formatted_content where school_num = $school_num and content_type = '$content_type'"; $results = db_query($query); if (db_num_rows($results) == 0) { $content_id = "$pac_name Web Password Reminder"; $content = "

Dear Parent,

\n

The following is your user id and password to access our $pac_name web site.

\n" . "

User ID: {userid}
\n" . "Password: {password}

\n" . "

You will need this information to access the web site, place lunch orders, view the event calendar, " . "post free classified ads and view the on-line bulletin boards.

\n" . "

$pac_name

\n"; $query = $formatted_content->BuildInsert(); db_query($query); } } // Create document type records if ($siteType == 'hotlunch') { $fp = fopen("document_types.txt","r"); $sequence = 1; while (!feof($fp)) { $cat = trim(fgets($fp,1000)); if (strlen($cat) > 0) { $results = db_query("select * from document_categories where school_num = $school_num and category = '$cat'"); if (db_num_rows($results) == 0) { db_query("insert into document_categories (school_num,category,sequence) values($school_num,'$cat',$sequence)"); $sequence++; } } } } } } // Create default email messages if ($siteType == 'hotlunch') { $content_type = 'E'; $content_id = db_escape_string("$school_name Lunch Money Due"); $query = "select * from formatted_content " . "where school_num = $school_num " . "and content_type = '$content_type' " . "and content_id = '$content_id'"; $results = db_query($query); if (db_num_rows($results) == 0) { $content_id = "$school_name Lunch Money Due"; $content = "

Dear Parent,

\n

We want to thank you for placing an order with the $pac_name Lunch Program. " . "This is a reminder that payment is now due for the lunch orders.

\n" . "

According to our records you have an outstanding balance at this time. If this is incorrect " . "please notify us so that we can correct our records.

\n" . "

System User ID: {userid}

\n" . "Balance Owing: " . '$' . "{account_balance}

\n" . "

Payment should be sent with your child to the school for processing.

\n" . "

Thank You $pac_name

\n"; $query = $formatted_content->BuildInsert(); db_query($query); } } // Create text data entries $text_data_tbl = new Table("text_data"); $date_added = date("Y-m-d",time()); $date_modified = date("Y-m-d",time()); $text_id = "Remittance Form"; $data_code = "Remittance"; $query = "select * from text_data where school_num = $school_num and text_id = '$text_id'"; $results = db_query($query); if (db_num_rows($results) == 0) { if ($siteType == 'registration') { $text_data = "When submitting payment please provide a single payment for all outstanding orders and please pay the full balance that is outstanding.\n\n" . "Payment can be made at the office."; } else { $text_data = "When submitting payment please provide a single payment for all outstanding orders and please pay the full balance that is outstanding.\n\n" . "Payment can be given to any teacher or handed in at the school office."; } $query = $text_data_tbl->BuildInsert(); db_query($query); } if ($siteType == 'hotlunch') { $text_id = "Lunch Reminder"; $data_code = "Lunch Reminder"; $query = "select * from text_data where school_num = $school_num and text_id = '$text_id'"; $results = db_query($query); if (db_num_rows($results) == 0) { $text_data = "Note: This is a reminder of your lunch order for the coming week.\n" . "\n" . "If you do not wish to receive the weekly lunch email reminder,\n" . "please login into your account at our site: https://$url\n" . "and edit your profile to disable the email message.\n"; $query = $text_data_tbl->BuildInsert(); db_query($query); } $text_id = "Lunch Reminder - No Service This Week"; $data_code = "Lunch Reminder"; $query = "select * from text_data where school_num = $school_num and text_id = '$text_id'"; $results = db_query($query); if (db_num_rows($results) == 0) { $text_data = "Note: There is no lunch service offered at school for the coming week.\n" . "\n" . "If you do not wish to receive the weekly lunch email reminder,\n" . "please login into your account at our site: https://$url\n" . "and edit your profile to disable the email message.\n"; $query = $text_data_tbl->BuildInsert(); db_query($query); } $text_id = "Parent Reminder"; $data_code = "Parent Reminder"; $query = "select * from text_data where school_num = $school_num and text_id = '$text_id'"; $results = db_query($query); if (db_num_rows($results) == 0) { $text_data = "Welcome to the $school_name Lunch Web Site. We have created a user account and password for you " . "when we entered your child's lunch order that you submitted as a paper order. If you wish to place " . "your lunch order using our on-line system for the upcoming session you will need the following user " . "id and password information.\n" . "\n" . "Once you login you will be able to change your user id, update your password, place lunch orders, " . "edit your contact information and view the on-line class list for your children's class. The contact " . "information you enter will only be available to other parents with children in the same class as your children.\n" . "\n" . "To access the Lunch web site:\n\n"; $query = $text_data_tbl->BuildInsert(); db_query($query); } $text_id = "Volunteer Reminder"; $data_code = "Volunteer Reminder"; $query = "select * from text_data where school_num = $school_num and text_id = '$text_id'"; $results = db_query($query); if (db_num_rows($results) == 0) { $text_data = "Just reminder that you are scheduled as a lunch volunteer this week. We look forward to seeing you."; $query = $text_data_tbl->BuildInsert(); db_query($query); } $text_id = "Registration Message"; $data_code = "Registration"; $query = "select * from text_data where school_num = $school_num and text_id = '$text_id'"; $results = db_query($query); if (db_num_rows($results) == 0) { $text_data = "Thank you for registering for a user account at the $school_name lunch web site. " . "You can now login to the web site. You will be able to update your contact information and register your students in the system for lunch ordering. " . "Registered users will be able to place lunch orders for their children and will receive email notices from the $pac_name."; $query = $text_data_tbl->BuildInsert(); db_query($query); } $text_id = "Staff Notice"; $data_code = "Staff"; $query = "select * from text_data where school_num = $school_num and text_id = '$text_id'"; $results = db_query($query); if (db_num_rows($results) == 0) { $text_data = "Welcome to the $pac_name Lunch Web Site. As a teacher on our site you will " . "be able to login and change your user id, update your password, place lunch orders " . "and view the on-line class list for your class.\n\n" . "The on-line class list will be generated from the set of students who participate in the " . "Lunch Program and may not be complete.\n\n" . "To access the Lunch web site:\n\n"; $query = $text_data_tbl->BuildInsert(); db_query($query); } } else { $text_id = "Registration Message"; $data_code = "Registration"; $query = "select * from text_data where school_num = $school_num and text_id = '$text_id'"; $results = db_query($query); if (db_num_rows($results) == 0) { $text_data = "Thank you for registering for a user account at the $school_name web site. " . "You can now login to the web site."; $query = $text_data_tbl->BuildInsert(); db_query($query); } $text_id = "Parent Reminder"; $data_code = "Parent Reminder"; $query = "select * from text_data where school_num = $school_num and text_id = '$text_id'"; $results = db_query($query); if (db_num_rows($results) == 0) { $text_data = "Welcome to the $school_name Fees Web Site. We have created a user account and password for you. " . "If you wish to access our on-line system for the upcoming session you will need the following user " . "id and password information.\n" . "\n" . "Once you login you will be able to change your password, place orders, and make payments.\n" . "\n" . "To access the web site:\n\n"; $query = $text_data_tbl->BuildInsert(); db_query($query); } $text_id = "Staff Notice"; $data_code = "Staff"; $query = "select * from text_data where school_num = $school_num and text_id = '$text_id'"; $results = db_query($query); if (db_num_rows($results) == 0) { $text_data = "Welcome to the $school_name Fees Web Site. As a teacher on our site you will " . "be able to login and update your password, place lunch orders " . "and view the on-line class list for your class.\n\n" . "The on-line class list will be generated from the set of students who participate in the " . "on-line program and may not be complete.\n\n" . "To access the web site:\n\n"; $query = $text_data_tbl->BuildInsert(); db_query($query); } } if ($event_calendar == 'Y') { db_query("INSERT INTO event_types (school_num,event_type_title,school_in_session,hotlunch_menu_on_date,display_on_order_form,text_color,bg_color) " . "VALUES ($school_num,'Holiday','N','Y','Y','FFFFFF','FF0000')"); db_query("INSERT INTO event_types (school_num,event_type_title,school_in_session,hotlunch_menu_on_date,display_on_order_form,text_color,bg_color) " . "VALUES ($school_num,'Special Event','Y','Y','N','FF0000','FFFFFF')"); db_query("INSERT INTO event_types (school_num,event_type_title,school_in_session,hotlunch_menu_on_date,display_on_order_form,text_color,bg_color) " . "VALUES ($school_num,'Council Event','Y','Y','N','FF0000','DDDDDD')"); db_query("INSERT INTO event_types (school_num,event_type_title,school_in_session,hotlunch_menu_on_date,display_on_order_form,text_color,bg_color) " . "VALUES ($school_num,'Other','Y','Y','N','000000','FFFFFF')"); if ($orgType == 'School' || $orgType == 'Elementary' || $orgType == 'Private') { db_query("INSERT INTO event_types (school_num,event_type_title,school_in_session,hotlunch_menu_on_date,display_on_order_form,text_color,bg_color) " . "VALUES ($school_num,'Lunch','Y','Y','N','000000','F0D060')"); db_query("INSERT INTO event_types (school_num,event_type_title,school_in_session,hotlunch_menu_on_date,display_on_order_form,text_color,bg_color) " . "VALUES ($school_num,'School Event','Y','Y','N','000000','FFFFFF')"); db_query("INSERT INTO event_types (school_num,event_type_title,school_in_session,hotlunch_menu_on_date,display_on_order_form,text_color,bg_color) " . "VALUES ($school_num,'Early Dismissal','Y','Y','N','000000','FF8000')"); db_query("INSERT INTO event_types (school_num,event_type_title,school_in_session,hotlunch_menu_on_date,display_on_order_form,text_color,bg_color) " . "VALUES ($school_num,'Professional Day','N','Y','Y','FF0000','FFFFFF')"); db_query("INSERT INTO event_types (school_num,event_type_title,school_in_session,hotlunch_menu_on_date,display_on_order_form,text_color,bg_color) " . "VALUES ($school_num,'Family Fun','Y','Y','N','FFFFFF','00A000')"); db_query("INSERT INTO event_types (school_num,event_type_title,school_in_session,hotlunch_menu_on_date,display_on_order_form,text_color,bg_color) " . "VALUES ($school_num,'Kid Friendly Activity','N','Y','N','FFFFFF','00A000')"); db_query("INSERT INTO event_types (school_num,event_type_title,school_in_session,hotlunch_menu_on_date,display_on_order_form,text_color,bg_color) " . "VALUES ($school_num,'Dance Event','Y','Y','N','000000','FFFFFF')"); db_query("INSERT INTO event_types (school_num,event_type_title,school_in_session,hotlunch_menu_on_date,display_on_order_form,text_color,bg_color) " . "VALUES ($school_num,'Musical Event','Y','Y','N','000000','FFFFFF')"); db_query("INSERT INTO event_types (school_num,event_type_title,school_in_session,hotlunch_menu_on_date,display_on_order_form,text_color,bg_color) " . "VALUES ($school_num,'Sporting Event','Y','Y','N','000000','FFFFFF')"); db_query("INSERT INTO event_types (school_num,event_type_title,school_in_session,hotlunch_menu_on_date,display_on_order_form,text_color,bg_color) " . "VALUES ($school_num,'Theatrical Event','Y','Y','N','000000','FFFFFF')"); } } ?>