1436 lines
67 KiB
PHP
1436 lines
67 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
|
|
$moduleName = "hotlunch_orders.save.php";
|
|
// if ($_SESSION['UserInfo']['type'] == 'SuperUser' || $_SESSION['UserInfo']['userid'] == 'mfester') startLog($moduleName);
|
|
// if ($school_num == 3) startLog($moduleName);
|
|
// startLog($moduleName);
|
|
|
|
$orderItemsText = "";
|
|
|
|
writeLog(print_r($_POST, true));
|
|
|
|
if (!isset($ordered_by_type)) $ordered_by_type = '';
|
|
if (array_key_exists('curr_ordered_by_type', $_POST)) $ordered_by_type = $_POST['curr_ordered_by_type'];
|
|
|
|
|
|
//
|
|
// Handle new student information
|
|
//
|
|
if ((!isset($student_num) || intval($student_num) == 0 || $student_num == '') && $num_items > 0 && isset($new_first_name) && strlen($new_first_name) > 0 &&
|
|
isset($new_last_name) && strlen($new_last_name) > 0) {
|
|
|
|
unset($userid);
|
|
writeLog("create new student\n");
|
|
|
|
// Default people type
|
|
$people_type = 'Student';
|
|
|
|
// Default user type
|
|
$type = 'Parent';
|
|
|
|
|
|
// Handle Guest Accounts
|
|
// if ((!isset($new_parent_first_name) && !isset($new_parent_last_name) && $school_record['registrations_permitted'] == 'Guest') || ($school_record['registrations_permitted'] == 'Both' && $new_class_num == 1)) {
|
|
// $new_parent_first_name = $new_first_name;
|
|
// $new_parent_last_name = $new_last_name;
|
|
// $people_type = 'Customer';
|
|
// $type = 'Guest';
|
|
// }
|
|
|
|
|
|
// Create new user record
|
|
if (!isset($existing_user_num) || intval($existing_user_num) == 0) {
|
|
writeLog("CREATE NEW USER");
|
|
$user_table = new Table("users");
|
|
unset($user_num);
|
|
|
|
// Handle situation where people enter "none" as email address
|
|
if (strlen($new_email) && $new_email == "none") $new_email = "";
|
|
|
|
// If an email address is provided then check to see if it is already in use
|
|
if (strlen($new_email) > 0) {
|
|
$results = db_query("select * from users where school_num = $base_school_num and email = '$new_email'");
|
|
if (db_num_rows($results) > 0) {
|
|
$row = db_fetch_array($results);
|
|
$userid = $row['userid'];
|
|
$user_num = $row['record_num'];
|
|
}
|
|
}
|
|
|
|
|
|
if (!isset($user_num) || intval($user_num) > 0) {
|
|
if ($school_record['registration_userid'] == 'Email' && strlen($new_email) > 0) {
|
|
$userid = $new_email;
|
|
}
|
|
|
|
if (!isset($userid) || strlen($userid) == 0) {
|
|
if (strlen($new_parent_first_name) > 0 || strlen($new_parent_last_name) > 0) {
|
|
$baseF = str_replace(" ","",trim($new_parent_first_name));
|
|
$baseL = str_replace(" ","",trim($new_parent_last_name));
|
|
$base = trim(str_replace("'","",$baseF));
|
|
if (strlen($base) || strlen($baseL)) {
|
|
if (strlen($base)) $base_userid = strtolower($base) . "." . strtolower(trim(str_replace("'","",$baseL)));
|
|
else $base_userid = strtolower($baseL);
|
|
}
|
|
$base_userid = str_replace(" ","",$base_userid);
|
|
$base_userid = str_replace("..",".",$base_userid);
|
|
$userid = $base_userid;
|
|
$count = 1;
|
|
}
|
|
else {
|
|
$base_userid = "school_account";
|
|
$query = "select userid from users " .
|
|
"where school_num = $base_school_num " .
|
|
"and userid like '$base_userid%' " .
|
|
"order by userid desc limit 0,1";
|
|
$id = db_getVal($query);
|
|
$count = 1;
|
|
if (strlen($id) > 0) $count = intval(str_replace($base_userid,"",$id)) + 1;
|
|
$userid = sprintf("%s%03d",$base_userid,$count);
|
|
}
|
|
|
|
// Check if the new userid is already in use
|
|
$uid = db_escape_string($userid);
|
|
$query = "select count(*) from users " .
|
|
"where school_num = $base_school_num " .
|
|
"and userid = '$uid'";
|
|
$num = db_getVal($query);
|
|
while ($num > 0) {
|
|
$userid = sprintf("%s%03d",$base_userid,$count);
|
|
$uid = db_escape_string($userid);
|
|
$query = "select count(*) from users " .
|
|
"where school_num = $base_school_num " .
|
|
"and userid = '$uid'";
|
|
$num = db_getVal($query);
|
|
$count++;
|
|
}
|
|
}
|
|
|
|
$password = $userid;
|
|
if (strlen(trim($new_email)) > 0) $email = trim($new_email);
|
|
$status = 'Active';
|
|
$added_time = date("Y-m-d H:i:s",time());
|
|
$date_added = date("Y-m-d",time());
|
|
$receive_emails = 'Y';
|
|
$email_reminders = 'N';
|
|
$first_name = trim($new_parent_first_name);
|
|
$last_name = trim($new_parent_last_name);
|
|
$home_phone = trim($new_phone);
|
|
$can_order = 'Yes';
|
|
|
|
$balance_owing = 0;
|
|
$account_balance = 0;
|
|
$num_orders = 0;
|
|
$has_order = 'N';
|
|
|
|
$temp_phone = preg_replace("/[^0-9]/","",$home_phone);
|
|
if (strlen($temp_phone) == 10) $home_phone = "(" . substr($temp_phone,0,3) . ")" . substr($temp_phone,3,3) . "-" . substr($temp_phone,6);
|
|
|
|
|
|
$entry = array();
|
|
|
|
if (isset($base_school_num)) $entry['school_num'] = $base_school_num;
|
|
if (isset($userid)) $entry['userid'] = $userid;
|
|
if (isset($password)) $entry['password'] = $password;
|
|
if (isset($password_crypt)) $entry['password_crypt'] = $password_crypt;
|
|
if (isset($change_datetime)) $entry['change_datetime'] = $change_datetime;
|
|
if (isset($email)) $entry['email'] = $email;
|
|
if (isset($email2)) $entry['email2'] = $email2;
|
|
if (isset($email3)) $entry['email3'] = $email3;
|
|
if (isset($include_email1_on_list)) $entry['include_email1_on_list'] = $include_email1_on_list;
|
|
if (isset($include_email2_on_list)) $entry['include_email2_on_list'] = $include_email2_on_list;
|
|
if (isset($include_email3_on_list)) $entry['include_email3_on_list'] = $include_email3_on_list;
|
|
if (isset($email1_verified)) $entry['email1_verified'] = $email1_verified;
|
|
if (isset($email2_verified)) $entry['email2_verified'] = $email2_verified;
|
|
if (isset($email3_verified)) $entry['email3_verified'] = $email3_verified;
|
|
if (isset($type)) $entry['type'] = $type;
|
|
if (isset($status)) $entry['status'] = $status;
|
|
if (isset($date_added)) $entry['date_added'] = $date_added;
|
|
if (isset($last_login)) $entry['last_login'] = $last_login;
|
|
if (isset($can_order)) $entry['can_order'] = $can_order;
|
|
if (isset($has_order)) $entry['has_order'] = $has_order;
|
|
if (isset($num_orders)) $entry['num_orders'] = $num_orders;
|
|
if (isset($num_students)) $entry['num_students'] = $num_students;
|
|
if (isset($source)) $entry['source'] = $source;
|
|
if (isset($ordered)) $entry['ordered'] = $ordered;
|
|
if (isset($paid)) $entry['paid'] = $paid;
|
|
if (isset($balance_owing)) $entry['balance_owing'] = $balance_owing;
|
|
if (isset($account_balance)) $entry['account_balance'] = $account_balance;
|
|
if (isset($trx_status)) $entry['trx_status'] = $trx_status;
|
|
if (isset($posted_date)) $entry['posted_date'] = $posted_date;
|
|
if (isset($receive_emails)) $entry['receive_emails'] = $receive_emails;
|
|
if (isset($email_reminders)) $entry['email_reminders'] = $email_reminders;
|
|
if (isset($email_flag)) $entry['email_flag'] = $email_flag;
|
|
if (isset($available_to_volunteer)) $entry['available_to_volunteer'] = $available_to_volunteer;
|
|
if (isset($class_parent)) $entry['class_parent'] = $class_parent;
|
|
if (isset($school_directory)) $entry['school_directory'] = $school_directory;
|
|
if (isset($email_list)) $entry['email_list'] = $email_list;
|
|
if (isset($language)) $entry['language'] = $language;
|
|
if (isset($first_name)) $entry['first_name'] = $first_name;
|
|
if (isset($last_name)) $entry['last_name'] = $last_name;
|
|
if (isset($first_name2)) $entry['first_name2'] = $first_name2;
|
|
if (isset($last_name2)) $entry['last_name2'] = $last_name2;
|
|
if (isset($home_phone)) $entry['home_phone'] = $home_phone;
|
|
if (isset($daytime_phone)) $entry['daytime_phone'] = $daytime_phone;
|
|
if (isset($cell_phone)) $entry['cell_phone'] = $cell_phone;
|
|
if (isset($address)) $entry['address'] = $address;
|
|
if (isset($city)) $entry['city'] = $city;
|
|
if (isset($province)) $entry['province'] = $province;
|
|
if (isset($postal)) $entry['postal'] = $postal;
|
|
if (isset($additional1)) $entry['additional1'] = $additional1;
|
|
if (isset($additional2)) $entry['additional2'] = $additional2;
|
|
if (isset($bank_account_holder)) $entry['bank_account_holder'] = $bank_account_holder;
|
|
if (isset($institution_number)) $entry['institution_number'] = $institution_number;
|
|
if (isset($branch_number)) $entry['branch_number'] = $branch_number;
|
|
if (isset($account_number)) $entry['account_number'] = $account_number;
|
|
if (isset($bambora_payment_profile_id)) $entry['bambora_payment_profile_id'] = $bambora_payment_profile_id;
|
|
if (isset($supplier_num)) $entry['supplier_num'] = $supplier_num;
|
|
if (isset($added_time)) $entry['added_time'] = $added_time;
|
|
if (isset($user_ip)) $entry['user_ip'] = $user_ip;
|
|
if (isset($enable_translation)) $entry['enable_translation'] = $enable_translation;
|
|
if (isset($linked_to_student)) $entry['linked_to_student'] = $linked_to_student;
|
|
if (isset($linked_to_num)) $entry['linked_to_num'] = $linked_to_num;
|
|
if (isset($linked_to_type)) $entry['linked_to_type'] = $linked_to_type;
|
|
if (isset($linked_id)) $entry['linked_id'] = $linked_id;
|
|
if (isset($linked_time)) $entry['linked_time'] = $linked_time;
|
|
if (isset($user_notes)) $entry['user_notes'] = $user_notes;
|
|
|
|
$query = $user_table->BuildInsert($entry);
|
|
writeLog("USER QUERY: $query");
|
|
db_query($query);
|
|
$user_num = db_insert_id();
|
|
|
|
|
|
//
|
|
// Send verification email to account
|
|
//
|
|
if ($school_record['status'] != 'Special' && ($source == 'On-line' || $school_record['send_registation_email_with_paper_orders'] == 'Y')) {
|
|
if ($_SESSION['UserInfo']['type'] != 'SuperUser' && isset($email) && strlen($email) > 0) {
|
|
include_once "include/queuemail.php";
|
|
|
|
$emailRecipient = "$first_name $last_name";
|
|
$emailTo = strtolower($email);
|
|
$emailReply = $school_record['reply_description'];
|
|
$emailFrom = setReplyAddress($school_record['support_email'],"notifications");
|
|
$emailSubject = $school_record['school_name'] . " Registration";
|
|
|
|
$schoolURL = $school_record['url'];
|
|
$emailMessage = str_replace("\r","",trim(db_getVal("SELECT text_data FROM text_data WHERE school_num = $school_num AND text_id = 'Registration Message'"))) .
|
|
"\n\n" .
|
|
sprintf("%20s: %s\n",getLanguageText('TEXT-WEB-ADDRESS'),"http://$schoolURL") .
|
|
sprintf("%20s: %s\n",getLanguageText('TEXT-USER-ID'),$userid) .
|
|
"\n";
|
|
if ($hotlunch_schedule['notification_order_details'] == 'Y') {
|
|
$emailMessage .= $orderItemsText .
|
|
"\n\n\n";
|
|
}
|
|
|
|
|
|
QueueEmail($emailTo, $emailFrom, $emailSubject, $emailMessage, $emailReply, $emailRecipient);
|
|
}
|
|
}
|
|
|
|
|
|
// Create new contact record
|
|
$contact_table = new Table("contacts");
|
|
$contact_type = 'Primary';
|
|
$first_name = trim($new_parent_first_name);
|
|
$last_name = trim($new_parent_last_name);
|
|
|
|
if ($display_contact_info == 'Y') {
|
|
$home_email = $new_email;
|
|
$home_phone = $new_phone;
|
|
}
|
|
else {
|
|
unset($home_phone);
|
|
}
|
|
|
|
$query = $contact_table->BuildInsert();
|
|
db_query($query);
|
|
}
|
|
|
|
}
|
|
else {
|
|
$user_num = intval($existing_user_num);
|
|
$results = db_query("select * from users where school_num = $base_school_num and record_num = $user_num");
|
|
$row = db_fetch_array($results);
|
|
$userid = $row['userid'];
|
|
$record_num = $row['record_num'];
|
|
|
|
// Update parent info if required
|
|
$first_name = trim($new_parent_first_name);
|
|
$last_name = trim($new_parent_last_name);
|
|
if (strlen(trim($new_email)) > 0) $email = trim($new_email);
|
|
|
|
$temp_phone = preg_replace("/[^0-9]/","",trim($new_phone));
|
|
if (strlen($temp_phone) == 10) $home_phone = "(" . substr($temp_phone,0,3) . ")" . substr($temp_phone,3,3) . "-" . substr($temp_phone,6);
|
|
|
|
if (isset($first_name) && $first_name != $row['first_name']) db_query("UPDATE users SET first_name = '" . db_escape_string($first_name) . "' WHERE record_num = $record_num");
|
|
if (isset($last_name) && $last_name != $row['last_name']) db_query("UPDATE users SET last_name = '" . db_escape_string($last_name) . "' WHERE record_num = $record_num");
|
|
if (isset($email) && $email != $row['email']) db_query("UPDATE users SET email = '" . db_escape_string($email) . "' WHERE record_num = $record_num");
|
|
if (isset($home_phone) && $home_phone != $row['home_phone']) db_query("UPDATE users SET home_phone = '" . db_escape_string($home_phone) . "' WHERE record_num = $record_num");
|
|
}
|
|
|
|
|
|
// Create new student record
|
|
$people_table = new Table("people");
|
|
$first_name = $new_first_name;
|
|
$last_name = $new_last_name;
|
|
if (isset($new_teacher_num)) $teacher_num = intval($new_teacher_num);
|
|
$class_num = 0;
|
|
if (isset($new_class_num)) $class_num = intval($new_class_num);
|
|
$meal_location = $class_num;
|
|
$status = 'Verified';
|
|
$display = 'Y';
|
|
$active = 'Y';
|
|
$added_date = date("Y-m-d",time());
|
|
$verified_date = $added_date;
|
|
$menu_price_category = 'Regular';
|
|
|
|
$numClasses = db_getVal("SELECT count(*) FROM classes WHERE school_num = $base_school_num");
|
|
if ($numClasses == 0) $class_num = 1;
|
|
$meal_location = $class_num;
|
|
|
|
unset($birthdate);
|
|
if ($school_record['collect_student_birthdate'] == 'Y') $birth_date = $birth_year . "-" . $birth_month . "-" . $birth_day;
|
|
|
|
$entry = array();
|
|
|
|
if (isset($base_school_num)) $entry['school_num'] = $base_school_num;
|
|
if (isset($user_num)) $entry['user_num'] = $user_num;
|
|
if (isset($title)) $entry['title'] = $title;
|
|
if (isset($first_name)) $entry['first_name'] = $first_name;
|
|
if (isset($last_name)) $entry['last_name'] = $last_name;
|
|
if (isset($email)) $entry['email'] = $email;
|
|
if (isset($label_note)) $entry['label_note'] = $label_note;
|
|
if (isset($birthdate)) $entry['birthdate'] = $birthdate;
|
|
if (isset($age)) $entry['age'] = $age;
|
|
if (isset($sex)) $entry['sex'] = $sex;
|
|
if (isset($school_grade)) $entry['school_grade'] = $school_grade;
|
|
if (isset($student_number)) $entry['student_number'] = $student_number;
|
|
if (isset($additional_permission)) $entry['additional_permission'] = $additional_permission;
|
|
if (isset($additional_permission_note)) $entry['additional_permission_note'] = $additional_permission_note;
|
|
if (isset($people_type)) $entry['people_type'] = $people_type;
|
|
if (isset($staff_category)) $entry['staff_category'] = $staff_category;
|
|
if (isset($staff_description)) $entry['staff_description'] = $staff_description;
|
|
if (isset($class_num)) $entry['class_num'] = $class_num;
|
|
if (isset($delivery_class_num)) $entry['delivery_class_num'] = $delivery_class_num;
|
|
if (isset($meal_location)) $entry['meal_location'] = $meal_location;
|
|
if (isset($status)) $entry['status'] = $status;
|
|
if (isset($display)) $entry['display'] = $display;
|
|
if (isset($active)) $entry['active'] = $active;
|
|
if (isset($menu_price_category)) $entry['menu_price_category'] = $menu_price_category;
|
|
if (isset($access_to_multiple_item_prices)) $entry['access_to_multiple_item_prices'] = $access_to_multiple_item_prices;
|
|
if (isset($diet_requests)) $entry['diet_requests'] = $diet_requests;
|
|
if (isset($cust_address)) $entry['cust_address'] = $cust_address;
|
|
if (isset($cust_city)) $entry['cust_city'] = $cust_city;
|
|
if (isset($cust_province)) $entry['cust_province'] = $cust_province;
|
|
if (isset($cust_country)) $entry['cust_country'] = $cust_country;
|
|
if (isset($cust_postal)) $entry['cust_postal'] = $cust_postal;
|
|
if (isset($cust_phone)) $entry['cust_phone'] = $cust_phone;
|
|
if (isset($cust_email)) $entry['cust_email'] = $cust_email;
|
|
if (isset($customer_of_person)) $entry['customer_of_person'] = $customer_of_person;
|
|
if (isset($added_date)) $entry['added_date'] = $added_date;
|
|
if (isset($customer_code)) $entry['customer_code'] = $customer_code;
|
|
if (isset($user_defined_value)) $entry['user_defined_value'] = $user_defined_value;
|
|
if (isset($user_defined_value2)) $entry['user_defined_value2'] = $user_defined_value2;
|
|
if (isset($user_defined_value3)) $entry['user_defined_value3'] = $user_defined_value3;
|
|
if (isset($user_defined_value4)) $entry['user_defined_value4'] = $user_defined_value4;
|
|
if (isset($user_defined_value5)) $entry['user_defined_value5'] = $user_defined_value5;
|
|
if (isset($user_defined_value6)) $entry['user_defined_value6'] = $user_defined_value6;
|
|
if (isset($user_defined_value7)) $entry['user_defined_value7'] = $user_defined_value7;
|
|
if (isset($user_defined_value8)) $entry['user_defined_value8'] = $user_defined_value8;
|
|
if (isset($user_defined_value9)) $entry['user_defined_value9'] = $user_defined_value9;
|
|
if (isset($user_defined_value10)) $entry['user_defined_value10'] = $user_defined_value10;
|
|
if (isset($notes)) $entry['notes'] = $notes;
|
|
if (isset($num_allergies)) $entry['num_allergies'] = $num_allergies;
|
|
|
|
$query = $people_table->BuildInsert($entry);
|
|
db_query($query);
|
|
|
|
$ordered_by_num = db_insert_id();
|
|
$ordered_by_type = 'Student';
|
|
}
|
|
else {
|
|
// Set current variables
|
|
if (isset($student_num)) writeLog("student_num: $student_num");
|
|
if (isset($ordered_by_num)) writeLog("ordered_by_num: $ordered_by_num");
|
|
if (isset($student_num) && !isset($ordered_by_num) && $student_num > 0) {
|
|
$ordered_by_num = $student_num;
|
|
if (!isset($ordered_by_type) || $ordered_by_type == '') $ordered_by_type = db_getVal("SELECT people_type FROM people WHERE school_num = $base_school_num AND record_num = $ordered_by_num");
|
|
}
|
|
}
|
|
|
|
|
|
if ($ordered_by_type != 'Concession') {
|
|
if (isset($ordered_by_num) && $ordered_by_num > 0) {
|
|
$ordered_by_type = db_getVal("SELECT people_type FROM people WHERE school_num = $base_school_num AND record_num = $ordered_by_num");
|
|
}
|
|
|
|
if (!isset($ordered_by_num) || $ordered_by_num == 0) {
|
|
$error_message = getLanguageText('ERRORMSG-NO-USER-OR-NO-ITEMS');
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
|
|
$uresults = db_query("select * from people where school_num = $base_school_num and record_num = $ordered_by_num");
|
|
if (db_num_rows($uresults) == 0) {
|
|
$error_message = getLanguageText('ERRORMSG-NO-USER-OR-NO-ITEMS');
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
$school_num = $school_record['record_num'];
|
|
|
|
// Check if this person has an order for this schedule
|
|
unset($onum);
|
|
if ($hotlunch_schedule['schedule_type'] == 'Hot Lunch' || $hotlunch_schedule['allow_multiple_orders'] != 'Y') {
|
|
$query = "select * from hotlunch_order_header " .
|
|
"where school_num = $school_num " .
|
|
"and ordered_by_num = $ordered_by_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
"order by record_num desc limit 0,1";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
if (db_num_rows($results) > 0) {
|
|
$oh = db_fetch_array($results);
|
|
$onum = $oh['record_num'];
|
|
$ostatus = $oh['status'];
|
|
writeLog("Order found - onum: $onum\n");
|
|
}
|
|
}
|
|
|
|
|
|
// Handle existing orders with an order_num parameter
|
|
if (isset($order_num) && $order_num > 0) {
|
|
$query = "select * from hotlunch_order_header " .
|
|
"where school_num = $school_num " .
|
|
"and ordered_by_num = $ordered_by_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
"and record_num = $order_num";
|
|
$results = db_query($query);
|
|
if (db_num_rows($results)) {
|
|
$oh = db_fetch_array($results);
|
|
$onum = $oh['record_num'];
|
|
$ostatus = $oh['status'];
|
|
writeLog("Existing order found - onum: $onum\n");
|
|
}
|
|
}
|
|
|
|
if (!isset($ostatus)) $ostatus = $school_record['default_order_status'];
|
|
|
|
$owhere = "";
|
|
if (isset($onum) && $onum > 0) {
|
|
$owhere = " and order_num = $onum ";
|
|
|
|
// Save order items if order status is Paid
|
|
if ($ostatus == 'Paid') {
|
|
db_query("DELETE FROM hotlunch_order_items_save WHERE school_num = $school_num AND order_num = $onum");
|
|
db_query("INSERT INTO hotlunch_order_items_save SELECT * FROM hotlunch_order_items WHERE school_num = $school_num AND order_num = $onum");
|
|
}
|
|
}
|
|
|
|
// Delete any existing hotlunch_order_items entries for this student and schedule
|
|
if (isset($onum) && $onum > 0 && ($naction == 'update' || $paction == 'edit')) {
|
|
$query = "select * from hotlunch_order_items " .
|
|
"where school_num = $school_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
"and ordered_by_num = $ordered_by_num " .
|
|
$owhere;
|
|
writeLog("query: $query\n");
|
|
$items = db_query($query);
|
|
writeLog("Num Items: ".db_num_rows($items));
|
|
while ($row = db_fetch_assoc($items)) {
|
|
$rnum = $row['record_num'];
|
|
$query = "DELETE FROM hotlunch_order_items WHERE school_num = $school_num AND record_num = $rnum";
|
|
writeLog($query);
|
|
db_query("DELETE FROM hotlunch_order_items WHERE school_num = $school_num AND record_num = $rnum");
|
|
}
|
|
}
|
|
|
|
if (!isset($price_category)) $price_category = 'Regular';
|
|
|
|
$hotlunch_order_items = new Table("hotlunch_order_items");
|
|
|
|
|
|
// Determine what the menu cutoff date is
|
|
$today = date("Y-m-d",time());
|
|
$first_menu_date = db_getVal("SELECT min(menu_date) FROM hotlunch_menu_dates WHERE school_num = $school_num AND schedule_num = $schedule_num AND menu_type = 'Regular'");
|
|
|
|
$menu_date_cutoff = date("Y-m-d",time() + ($hotlunch_schedule['days_prior_to_order_date']) * 60 * 60 * 24);
|
|
writeLog("menu_date_cutoff: $menu_date_cutoff");
|
|
if (strlen($hotlunch_schedule['end_order_datetime']) && $hotlunch_schedule['end_order_datetime'] < $first_menu_date) $menu_date_cutoff = $today;
|
|
writeLog("menu_date_cutoff: $menu_date_cutoff");
|
|
if (strlen($hotlunch_schedule['menu_cutoff_date']) && $hotlunch_schedule['menu_cutoff_date'] > $today) $menu_date_cutoff = $hotlunch_schedule['menu_cutoff_date'];
|
|
writeLog("menu_date_cutoff: $menu_date_cutoff");
|
|
if (strlen($menu_date_cutoff) == 0) $menu_date_cutoff = date("Y-m-d",time() + ($hotlunch_schedule['days_prior_to_order_date']) * 60 * 60 * 24);
|
|
writeLog("menu_date_cutoff: $menu_date_cutoff");
|
|
|
|
if ($hotlunch_schedule['schedule_type'] != 'Hot Lunch') {
|
|
if (isset($first_menu_date) && is_string($first_menu_date) && strlen($first_menu_date)) $menu_date_cutoff = $first_menu_date;
|
|
}
|
|
|
|
$numPriorToCutoff = 0;
|
|
$query = "SELECT count(*) FROM hotlunch_menu_dates " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND menu_type = 'Regular' " .
|
|
"AND menu_date < '$menu_date_cutoff'";
|
|
writeLog("query: $query");
|
|
$numPriorToCutoff = db_getVal("SELECT count(*) FROM hotlunch_menu_dates WHERE school_num = $school_num AND schedule_num = $schedule_num AND menu_type = 'Regular' AND menu_date < '$menu_date_cutoff'");
|
|
|
|
writeLog("numPriorToCutoff: $numPriorToCutoff");
|
|
|
|
|
|
// Process each menu and menu item in the schedule
|
|
$query = "select * from hotlunch_menu_dates " .
|
|
"where school_num = $school_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
"order by sequence,menu_date";
|
|
$menu_dates = db_query($query);
|
|
|
|
$num_items = 0;
|
|
|
|
writeLog("ordered_by_type: $ordered_by_type");
|
|
if ($ordered_by_type != 'Concession') {
|
|
// Get user_num for current person
|
|
$uresults = db_query("select * from people where school_num = $base_school_num and record_num = $ordered_by_num");
|
|
if (db_num_rows($uresults)) {
|
|
$precord = db_fetch_assoc($uresults);
|
|
$user_num = $precord['user_num'];
|
|
$ordered_by_first_name = $precord['first_name'];
|
|
$ordered_by_last_name = $precord['last_name'];
|
|
}
|
|
}
|
|
else {
|
|
$ordered_by_num = $school_num;
|
|
}
|
|
|
|
|
|
while ($menu_date = db_fetch_array($menu_dates)) {
|
|
$menu_num = $menu_date['record_num'];
|
|
$menu_code = $schedule_num . "_" . $menu_num;
|
|
$menu_date = $menu_date['menu_date'];
|
|
|
|
// Check for volunteer signups
|
|
if ($ordered_by_type != 'Concession' && $user_num > 0) {
|
|
if (isset($_POST["volunteer_$menu_code"])) {
|
|
if (array_key_exists("volunteer_$menu_code", $_POST) && $_POST["volunteer_$menu_code"] == 'Y') {
|
|
$vnum = db_getVal("SELECT count(*) FROM hotlunch_volunteers WHERE school_num = $school_num AND schedule_num = $schedule_num AND menu_num = $menu_num AND user_num = $user_num AND deleted != 'Y'");
|
|
if ($vnum == 0) db_query("INSERT INTO hotlunch_volunteers (school_num, schedule_num, menu_num, user_num, people_num, deleted) " .
|
|
"VALUES ($school_num,$schedule_num,$menu_num,$user_num,$ordered_by_num,'N')");
|
|
db_query("UPDATE users SET available_to_volunteer = 'Y' where school_num = $base_school_num AND record_num = $user_num");
|
|
}
|
|
else {
|
|
db_query("DELETE FROM hotlunch_volunteers WHERE school_num = $school_num AND schedule_num = $schedule_num AND menu_num = $menu_num AND user_num = $user_num");
|
|
}
|
|
}
|
|
}
|
|
|
|
// Get menu items for this menu date
|
|
$query = "select * from hotlunch_menu_items " .
|
|
"where school_num = $school_num " .
|
|
"and menu_num = $menu_num " .
|
|
"and item_type = 'Item' " .
|
|
"order by sequence";
|
|
$menu_items = db_query($query);
|
|
|
|
$order_num = 0;
|
|
if (isset($entered_order_num) && $entered_order_num > 0) $order_num = $entered_order_num;
|
|
if (!isset($entered_order_num)) $entered_order_num = 0;
|
|
|
|
$category_savings = 0.00;
|
|
|
|
while ($menu_item = db_fetch_array($menu_items)) {
|
|
$menu_item_num = $menu_item['record_num'];
|
|
$options = $menu_item['options'];
|
|
$options2 = $menu_item['options2'];
|
|
$options3 = $menu_item['options3'];
|
|
$taxable_item = $menu_item['taxable_item'];
|
|
$source_item = $menu_item['source_item'];
|
|
$online_price = $menu_item['online_price'];
|
|
$menu_item_title = $menu_item['item_title'];
|
|
|
|
$curr_code = $schedule_num . "_" . $menu_num . "_" . $menu_item_num;
|
|
$qty = 0;
|
|
$price = 0;
|
|
if (array_key_exists("qty_$curr_code", $_POST)) $qty = $_POST["qty_$curr_code"];
|
|
if (array_key_exists("price_$curr_code", $_POST)) $price = floatval($_POST["price_$curr_code"]) * 100;
|
|
if (array_key_exists("alt_prices_$curr_code", $_POST)) $price = floatval($_POST["alt_prices_$curr_code"]) * 100;
|
|
if (array_key_exists("alt_prices_hidden_$curr_code", $_POST)) $price = floatval($_POST["alt_prices_hidden_$curr_code"]) * 100;
|
|
writeLog("$price - $menu_item_title");
|
|
|
|
if ($qty > 0) {
|
|
// Handle item options
|
|
$options_ordered = "";
|
|
if (strlen($options) > 0) {
|
|
$item_options = explode("\n",$options);
|
|
for ($i = 0; $i < count($item_options); $i++) {
|
|
$option = trim($item_options[$i]);
|
|
$option_f = str_replace(" ","_",substr($option,0,30));
|
|
$option_f = str_replace("&","and",$option_f);
|
|
$option_f = preg_replace("/[^a-zA-Z0-9_]/","",$option_f);
|
|
$opt_name = "option_$curr_code" . "_$option_f";
|
|
if (array_key_exists($opt_name, $_POST) && $_POST[$opt_name] == 'Y') $options_ordered .= "$option\n";
|
|
}
|
|
}
|
|
|
|
// Check for a source item options if there are none on this item
|
|
if (strlen(trim($options_ordered)) == 0 && $source_item > 0 && $numPriorToCutoff == 0) {
|
|
$source_options_ordered = db_getVal("SELECT options_ordered FROM hotlunch_order_items " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND order_num = $order_num " .
|
|
"AND ordered_by_num = $ordered_by_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND menu_item_num = $source_item");
|
|
if (strlen($source_options_ordered)) $options_ordered = $source_options_ordered;
|
|
}
|
|
$options_ordered = trim($options_ordered);
|
|
|
|
|
|
// Handle item options2
|
|
$options2_ordered = "";
|
|
if (strlen($options2) > 0) {
|
|
$item_options = explode("\n",$options2);
|
|
for ($i = 0; $i < count($item_options); $i++) {
|
|
$option = trim($item_options[$i]);
|
|
$option_f = str_replace(" ","_",substr($option,0,30));
|
|
$option_f = str_replace("&","and",$option_f);
|
|
$option_f = preg_replace("/[^a-zA-Z0-9_]/","",$option_f);
|
|
$opt_name = "option2_$curr_code" . "_$option_f";
|
|
if (array_key_exists($opt_name, $_POST) && $_POST[$opt_name] == 'Y') $options2_ordered .= "$option\n";
|
|
}
|
|
}
|
|
|
|
// Check for a source item options if there are none on this item
|
|
if (strlen(trim($options2_ordered)) == 0 && $source_item > 0 && $numPriorToCutoff == 0) {
|
|
$source_options2_ordered = db_getVal("SELECT options2_ordered FROM hotlunch_order_items " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND order_num = $order_num " .
|
|
"AND ordered_by_num = $ordered_by_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND menu_item_num = $source_item");
|
|
if (strlen($source_options2_ordered)) $options2_ordered = $source_options2_ordered;
|
|
}
|
|
$options2_ordered = trim($options2_ordered);
|
|
|
|
// Handle item options3
|
|
$options3_ordered = "";
|
|
if (strlen($options3) > 0) {
|
|
$item_options = explode("\n",$options3);
|
|
for ($i = 0; $i < count($item_options); $i++) {
|
|
$option = trim($item_options[$i]);
|
|
$option_f = str_replace(" ","_",substr($option,0,30));
|
|
$option_f = str_replace("&","and",$option_f);
|
|
$option_f = preg_replace("/[^a-zA-Z0-9_]/","",$option_f);
|
|
$opt_name = "option3_$curr_code" . "_$option_f";
|
|
if (array_key_exists($opt_name, $_POST) && $_POST[$opt_name] == 'Y') $options3_ordered .= "$option\n";
|
|
}
|
|
}
|
|
|
|
// Check for a source item options if there are none on this item
|
|
if (strlen(trim($options3_ordered)) == 0 && $source_item > 0 && $numPriorToCutoff == 0) {
|
|
$source_options3_ordered = db_getVal("SELECT options3_ordered FROM hotlunch_order_items " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND order_num = $order_num " .
|
|
"AND ordered_by_num = $ordered_by_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND menu_item_num = $source_item");
|
|
if (strlen($source_options3_ordered)) $options3_ordered = $source_options3_ordered;
|
|
}
|
|
$options3_ordered = trim($options3_ordered);
|
|
|
|
|
|
// Calculate the extended price and save the data
|
|
$price = floatval($price);
|
|
$extended_price = number_format((intval($qty * $price) / 100),2);
|
|
$active = 'Y';
|
|
$menu_item_price = number_format(($price / 100),2);
|
|
writeLog("menu_item_price: $menu_item_price ---------------------------------");
|
|
$item_added_date = date("Y-m-d",time());
|
|
$query = $hotlunch_order_items->BuildInsert();
|
|
writeLog($query);
|
|
db_query($query);
|
|
$rnum = db_insert_id();
|
|
writeLog("rnum: $rnum");
|
|
$num_items++;
|
|
|
|
$ititle = $menu_item_title;
|
|
if (strlen($ititle) > 45) $ititle = substr($ititle,0,42) . "...";
|
|
$iprice = $school_record['currency_symbol'] . number_format(($price / 100),2);
|
|
$iextended = $school_record['currency_symbol'] . $extended_price;
|
|
|
|
$orderItemsText .= sprintf("%-45s %3d @ %-7s: %-12s\n",$ititle,$qty,$iprice,$iextended);
|
|
|
|
// Calculate category savings
|
|
// if (isset($price_category) && $price_category != 'Regular') {
|
|
if ($menu_item_price < $online_price) {
|
|
$full_price = $qty * $online_price;
|
|
$category_savings += $full_price - $extended_price;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Check for duplicate ordered menu items
|
|
$query = "SELECT school_num, schedule_num, ordered_by_num, menu_item_num, count( * ) " .
|
|
"FROM hotlunch_order_items " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND ordered_by_num = $ordered_by_num " .
|
|
"GROUP BY 1, 2, 3, 4 " .
|
|
"HAVING count( * ) > 1 " .
|
|
"ORDER BY 1,2,3";
|
|
writeLog("Check for Duplicates - query: $query\n");
|
|
$duplicates = db_query($query);
|
|
writeLog("Duplicates Found: ".db_num_rows($duplicates));
|
|
if (db_num_rows($duplicates)) {
|
|
writeLog("Duplicates found\n");
|
|
$pnum = 0;
|
|
while ($row = db_fetch_assoc($duplicates)) {
|
|
$menu_item_num = $row['menu_item_num'];
|
|
$query = "SELECT * FROM hotlunch_order_items " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND ordered_by_num = $ordered_by_num " .
|
|
"AND menu_item_num = $menu_item_num";
|
|
$results = db_query($query);
|
|
$item_num = 0;
|
|
while ($row = db_fetch_assoc($results)) {
|
|
if ($item_num == $row['menu_item_num']) {
|
|
$rnum = $row['record_num'];
|
|
db_query("DELETE FROM hotlunch_order_items WHERE record_num = $rnum");
|
|
}
|
|
$item_num = $row['menu_item_num'];
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
writeLog("num_items: $num_items\n");
|
|
|
|
|
|
// If there are no order items then delete the header and any account entry
|
|
if ($num_items == 0 && $ordered_by_type != 'Concession') {
|
|
logOrderChange($order_num, "ORDER DELETED - NO ITEMS", "hotlunch_orders.save.php");
|
|
$query = "delete from hotlunch_order_header " .
|
|
"where school_num = $school_num " .
|
|
"and ordered_by_num = $ordered_by_num " .
|
|
"and schedule_num = $schedule_num";
|
|
writeLog("query: $query\n");
|
|
db_query($query);
|
|
|
|
$query = "delete from hotlunch_order_items " .
|
|
"where school_num = $school_num " .
|
|
"and ordered_by_num = $ordered_by_num " .
|
|
"and schedule_num = $schedule_num";
|
|
writeLog("query: $query\n");
|
|
db_query($query);
|
|
|
|
db_query("delete from user_account " .
|
|
"where school_num = $school_num " .
|
|
"and user_num = $user_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
"and people_num = $ordered_by_num" .
|
|
"and transaction_type = 'Order'");
|
|
|
|
calcSiblingDiscounts($user_num,$schedule_num);
|
|
|
|
$order_num = 0;
|
|
$error_message = getLanguageText('ERRORMSG-ORDER-HAS-NO-ITEMS-NOT-ENTERED');
|
|
|
|
echo("<center>\n");
|
|
|
|
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Application Volunteer','Schedule Volunteer','Administration Team','Schedule Team','Supplier');
|
|
if (checkPermission($AllowedUserTypes) == 1) {
|
|
include "hotlunch_reports.menu.php";
|
|
include "hotlunch_orders.options.php";
|
|
}
|
|
echo("<br>\n");
|
|
include "form.messages.php";
|
|
echo("</center>\n");
|
|
return;
|
|
}
|
|
|
|
|
|
// Handle existing order_num
|
|
$owhere = "and order_num = 0 ";
|
|
if (isset($onum) && $onum > 0) {
|
|
$owhere = "and order_num = $onum ";
|
|
}
|
|
|
|
// Get order total
|
|
$query = "select sum(qty) as num, sum(extended_price) as order_subtotal " .
|
|
"from hotlunch_order_items " .
|
|
"where school_num = $school_num " .
|
|
"and ordered_by_num = $ordered_by_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
$owhere .
|
|
"and active != 'N'";
|
|
$results = db_query($query);
|
|
$row = db_fetch_array($results);
|
|
|
|
$number_items = $row['num'];
|
|
$order_subtotal = $row['order_subtotal'];
|
|
$ordertotal = $order_subtotal;
|
|
$order_total = $order_subtotal;
|
|
if (!isset($discount_amount)) $discount_amount = 0;
|
|
|
|
if (!isset($source) || strlen($source) == 0) $source = 'On-Line';
|
|
|
|
// Handle any discounts
|
|
$today = date("Y-m-d",time());
|
|
if ($ordered_by_type != 'Concession' && $source == 'On-Line' &&
|
|
isset($hotlunch_schedule['discount_offered']) && $hotlunch_schedule['discount_offered'] > 0 &&
|
|
$hotlunch_schedule['discount_expiry_date'] >= $today) {
|
|
$discount_offered = $hotlunch_schedule['discount_offered'];
|
|
$discount_type = $hotlunch_schedule['discount_type'];
|
|
$discount_order_minimum = $hotlunch_schedule['discount_order_minimum'];
|
|
|
|
if ($order_total >= $discount_order_minimum) {
|
|
if ($discount_type == 'Amount') {
|
|
$discount_amount = $discount_offered;
|
|
}
|
|
else {
|
|
$discount_amount = $order_subtotal * $discount_offered / 100;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Apply the discount amount
|
|
$order_total = $order_subtotal - $discount_amount;
|
|
|
|
|
|
// Handle any late charges
|
|
$late_charge_amount = 0;
|
|
if (!isset($apply_late_charge)) $apply_late_charge = '';
|
|
if ($ordered_by_type != 'Concession' && $apply_late_charge == 'Y') {
|
|
$late_charge = $hotlunch_schedule['late_charge'];
|
|
$late_charge_date = $hotlunch_schedule['late_charge_date'];
|
|
|
|
if ($late_charge > 0 && $late_charge_date <= $today) {
|
|
$late_charge_amount = $late_charge;
|
|
}
|
|
}
|
|
|
|
|
|
// Calculate any taxes
|
|
$tax_charge_amount = 0;
|
|
if ($hotlunch_schedule['tax_rate'] > 0.00) {
|
|
$tax_rate = floatval($hotlunch_schedule['tax_rate']);
|
|
$tax_description = $hotlunch_schedule['tax_description'];
|
|
|
|
$query = "select sum(extended_price) " .
|
|
"from hotlunch_order_items " .
|
|
"where school_num = $school_num " .
|
|
"and ordered_by_num = $ordered_by_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
$owhere .
|
|
"and active != 'N' " .
|
|
"and taxable_item = 'Y'";
|
|
$taxable_total = db_getVal($query);
|
|
$taxable_total = floatval($taxable_total);
|
|
$tax_charge_amount = round($tax_rate * $taxable_total / 100,2);
|
|
|
|
}
|
|
|
|
|
|
// Create an order header record if required
|
|
$added_time = time();
|
|
$added_date = date("Y-m-d",$added_time);
|
|
$updated_date = $added_date;
|
|
$amount_paid = 0;
|
|
|
|
$hotlunch_order_header = new Table("hotlunch_order_header");
|
|
$hotlunch_order_log = new Table("hotlunch_order_log");
|
|
// startLog("hotlunch_orders.save.php");
|
|
|
|
writeLog("naction: $naction\n");
|
|
if (isset($onum)) writeLog("onum: $onum\n");
|
|
if (isset($entered_order_num)) writeLog("entered_order_num: $entered_order_num\n");
|
|
|
|
// Update existing order header otherwise
|
|
if ((isset($onum) && $onum > 0) || ($naction == 'update' && isset($entered_order_num) && $entered_order_num > 0)) {
|
|
$record_num = $entered_order_num;
|
|
$order_num = $entered_order_num;
|
|
if (isset($onum) && $onum > 0) $order_num = $onum;
|
|
$entered_by = $_SESSION['UserInfo']['record_num'];
|
|
if ($entered_by == 1) $entered_by = db_getVal("SELECT entered_by FROM hotlunch_order_header WHERE record_num = $order_num");
|
|
|
|
if ($ordered_by_type != 'Concession') $ordered_by_type = db_getVal("SELECT people_type FROM people WHERE school_num = $base_school_num AND record_num = $ordered_by_num");
|
|
if ($ordered_by_type == 'Concession') $status = 'Concession';
|
|
|
|
$amount_paid = db_getVal("SELECT amount_paid FROM hotlunch_order_header WHERE record_num = $order_num");
|
|
|
|
// Calculate the order cost
|
|
$query = "select sum(hloi.qty * hlmp.supplier_product_qty * (sp.package_cost / sp.package_qty)) as cost " .
|
|
"from hotlunch_order_items as hloi, hotlunch_menu_products as hlmp, supplier_products as sp " .
|
|
"where hloi.school_num = $school_num " .
|
|
"and hlmp.school_num = $school_num " .
|
|
"and sp.school_num = $supplier_school_num " .
|
|
"and hloi.order_num = $order_num " .
|
|
"and hloi.schedule_num = $schedule_num " .
|
|
"and hloi.menu_item_num = hlmp.menu_item_num " .
|
|
"and hlmp.supplier_product_num = sp.record_num " .
|
|
$owhere;
|
|
$order_cost = floatval(db_getVal($query));
|
|
|
|
$order_subtotal = floatval($order_subtotal);
|
|
$order_total = floatval($order_total);
|
|
|
|
if (!isset($order_notes)) $order_notes = '';
|
|
if (!isset($order_notes2)) $order_notes2 = '';
|
|
if (!isset($price_category)) $price_category = 'Regular';
|
|
|
|
$order_notes = db_escape_string($order_notes);
|
|
$order_notes2 = db_escape_string($order_notes2);
|
|
|
|
// Update order status
|
|
if ($ostatus == 'Paid') {
|
|
$order_status = 'Unpaid';
|
|
if ($order_total <= $amount_paid) $order_status = 'Paid';
|
|
}
|
|
else {
|
|
$order_status = $ostatus;
|
|
}
|
|
|
|
|
|
// Build query
|
|
if ($ordered_by_type == '') $ordered_by_type = 'Student';
|
|
$query = "update hotlunch_order_header " .
|
|
"set order_subtotal = $order_subtotal, " .
|
|
"discount_amount = $discount_amount, " .
|
|
"order_total = $order_total, " .
|
|
"order_cost = $order_cost, " .
|
|
"status = '$order_status', " .
|
|
"ordered_by_type = '$ordered_by_type', " .
|
|
"updated_date = '$updated_date', " .
|
|
"entered_by = $entered_by, " .
|
|
"order_notes = '$order_notes', " .
|
|
"order_notes2 = '$order_notes2', " .
|
|
"price_category = '$price_category', " .
|
|
"category_savings = $category_savings ".
|
|
"where school_num = $school_num " .
|
|
"and ordered_by_num = $ordered_by_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
"and record_num = $order_num";
|
|
db_query($query);
|
|
writeLog("query: $query\n");
|
|
|
|
logOrderChange($order_num, "ORDER UPDATED", "hotlunch_orders.save.php");
|
|
|
|
if ($order_status == 'Paid') db_query("DELETE FROM hotlunch_order_items_save WHERE school_num = $school_num AND order_num = $order_num");
|
|
|
|
// Set trx status to Open for posting additional payments
|
|
if ($order_status == 'Unpaid') {
|
|
db_query("UPDATE user_account SET transaction_status = 'Open' WHERE school_num = $school_num AND transaction_type = 'Order' AND order_num = $order_num");
|
|
}
|
|
|
|
// Update hotlunch_order_items with order_num
|
|
$query = "update hotlunch_order_items " .
|
|
"set order_num = $order_num, " .
|
|
"active = 'Y' " .
|
|
"where school_num = $school_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
"and ordered_by_type = '$ordered_by_type' " .
|
|
"and ordered_by_num = $ordered_by_num " .
|
|
"and order_num in (0,$order_num)";
|
|
db_query($query);
|
|
writeLog("query: $query\n");
|
|
|
|
// Log this order change
|
|
$entered_time = time();
|
|
$entered_datetime = date("Y-m-d H:i:s",$entered_time);
|
|
writeLog("order_status: $order_status");
|
|
$status = $order_status;
|
|
writeLog("status: $status");
|
|
$query = $hotlunch_order_log->BuildInsert();
|
|
writeLog($query);
|
|
db_query($query);
|
|
|
|
}
|
|
else {
|
|
// Create new order header on insert
|
|
$order_subtotal = floatval($order_subtotal);
|
|
$order_total = floatval($order_total);
|
|
$entered_by = $_SESSION['UserInfo']['record_num'];
|
|
$delivered = 'N';
|
|
|
|
if (!isset($price_category)) $price_category = 'Regular';
|
|
switch ($price_category) {
|
|
case 'Regular':
|
|
default:
|
|
$status = $school_record['default_order_status'];
|
|
break;
|
|
|
|
case 'Special 1':
|
|
$status = $school_record['default_order_status_special1'];
|
|
break;
|
|
|
|
case 'Special 2':
|
|
$status = $school_record['default_order_status_special2'];
|
|
break;
|
|
|
|
case 'Special 3':
|
|
$status = $school_record['default_order_status_special3'];
|
|
break;
|
|
}
|
|
|
|
$school_num = $school_record['record_num'];
|
|
$query = $hotlunch_order_header->BuildInsert();
|
|
writeLog("query: $query\n");
|
|
db_query($query);
|
|
$order_num = db_insert_id();
|
|
|
|
// Update hotlunch_order_items with order_num
|
|
$query = "update hotlunch_order_items " .
|
|
"set order_num = $order_num, " .
|
|
"active = 'Y' " .
|
|
"where school_num = $school_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
"and ordered_by_type = '$ordered_by_type' " .
|
|
"and ordered_by_num = $ordered_by_num " .
|
|
"and order_num in (0,$order_num)";
|
|
writeLog("query: $query\n");
|
|
db_query($query);
|
|
|
|
logOrderChange($order_num, "ORDER INSERTED", "hotlunch_orders.save.php");
|
|
|
|
// Log this order change
|
|
$entered_time = time();
|
|
$entered_datetime = date("Y-m-d H:i:s",$entered_time);
|
|
$query = $hotlunch_order_log->BuildInsert();
|
|
db_query($query);
|
|
}
|
|
|
|
|
|
|
|
// Get person's name
|
|
switch ($ordered_by_type) {
|
|
case 'Student':
|
|
case 'Staff':
|
|
case 'Customer':
|
|
$query = "select concat_ws(' ',first_name,last_name) from people " .
|
|
"where school_num = $base_school_num " .
|
|
"and record_num = $ordered_by_num";
|
|
$current_name = db_getVal($query);
|
|
break;
|
|
|
|
case 'Concession':
|
|
$current_name = 'Concession';
|
|
break;
|
|
}
|
|
|
|
|
|
// Post user account transaction
|
|
if ($ordered_by_type != 'Concession') {
|
|
$user_num = intval(db_getVal("select user_num from people where school_num = $base_school_num and record_num = $ordered_by_num"));
|
|
$query = "select count(*) from user_account " .
|
|
"where school_num = $school_num " .
|
|
"and user_num = $user_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
"and people_num = $ordered_by_num " .
|
|
"AND (deleted != 'Y' OR deleted IS NULL) " .
|
|
$owhere;
|
|
writeLog("query: $query\n");
|
|
$count = db_getVal($query);
|
|
|
|
if ($count == 0) {
|
|
$datetime = date("Y-m-d H:i:s",time());
|
|
$entered_time = time();
|
|
$cname = db_escape_string($current_name);
|
|
|
|
// Create user_account entry for current order
|
|
$order_total = floatval($order_total);
|
|
$query = "INSERT INTO user_account (school_num,user_num,schedule_num,order_num,people_num,transaction_datetime,transaction_type,note,transaction_amount,deleted,entered_time,transaction_status) " .
|
|
"VALUES ($school_num,$user_num,$schedule_num,$order_num,$ordered_by_num,'$datetime','Order','Order for $cname',$order_total,'N',$entered_time,'Open')";
|
|
writeLog("query: $query\n");
|
|
db_query($query);
|
|
}
|
|
else {
|
|
$query = "update user_account " .
|
|
"set transaction_amount = $order_total " .
|
|
"where school_num = $school_num " .
|
|
"and user_num = $user_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
"and people_num = $ordered_by_num " .
|
|
"and transaction_type = 'Order' " .
|
|
$owhere;
|
|
writeLog("query: $query\n");
|
|
db_query($query);
|
|
}
|
|
|
|
// Delete any incorrect entries for this order
|
|
$query = "SELECT * FROM user_account " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND user_num != $user_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND people_num = $ordered_by_num " .
|
|
"AND transaction_type = 'Order'";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
if (db_num_rows($results)) {
|
|
while ($row = db_fetch_assoc($results)) {
|
|
$rnum = $row['record_num'];
|
|
$query = "DELETE FROM user_account WHERE school_num = $school_num AND record_num = $rnum";
|
|
db_query($query);
|
|
}
|
|
}
|
|
|
|
|
|
// If the order status is Complimentary update credit transaction amount
|
|
$order_status = $ostatus;
|
|
if (isset($ostatus) && $ostatus == 'Complimentary') {
|
|
$credit_amount = -1 * $order_total;
|
|
$query = "UPDATE user_account SET transaction_amount = $credit_amount " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND user_num = $user_num " .
|
|
"AND order_num = $order_num " .
|
|
"AND transaction_type = 'Complimentary Credit'";
|
|
db_query($query);
|
|
}
|
|
|
|
|
|
// Create paper order charge entry if required
|
|
$paper_order_charge = $hotlunch_schedule['paper_order_charge'];
|
|
$paper_order_message = db_escape_string($hotlunch_schedule['paper_order_message']);
|
|
if ($paper_order_charge > 0 && $source == 'Paper') {
|
|
// Determine if there is already a paper order charge for this order
|
|
$results = db_query("SELECT * FROM user_account WHERE school_num = $school_num AND user_num = $user_num AND order_num = $order_num AND transaction_type = 'Paper Order Charge' AND deleted = 'N'");
|
|
|
|
if (db_num_rows($results) == 0) {
|
|
$datetime = date("Y-m-d H:i:s",time());
|
|
$entered_time = time();
|
|
$entered_user_num = intval($_SESSION['UserInfo']['record_num']);
|
|
$paper_order_charge = floatval($paper_order_charge);
|
|
$query = "INSERT INTO user_account (school_num,user_num,schedule_num,order_num,people_num,transaction_datetime,transaction_type,note,transaction_amount," .
|
|
"deleted,entered_time,entered_by_user_num) " .
|
|
"VALUES ($school_num,$user_num,$schedule_num,$order_num,$ordered_by_num,'$datetime','Paper Order Charge','$paper_order_message',$paper_order_charge," .
|
|
"'N',$entered_time,$entered_user_num)";
|
|
db_query($query);
|
|
}
|
|
}
|
|
|
|
|
|
// Create late charge entry if required
|
|
if ($late_charge_amount > 0) {
|
|
// Determine if there is already a late charge for this order
|
|
$results = db_query("SELECT * FROM user_account WHERE school_num = $school_num AND user_num = $user_num AND order_num = $order_num AND transaction_type = 'Late Charge' AND deleted = 'N'");
|
|
|
|
if (db_num_rows($results) == 0) {
|
|
$datetime = date("Y-m-d H:i:s",time());
|
|
$entered_time = time();
|
|
$entered_user_num = intval($_SESSION['UserInfo']['record_num']);
|
|
$late_charge_amount = floatval($late_charge_amount);
|
|
$query = "INSERT INTO user_account (school_num,user_num,schedule_num,order_num,people_num,transaction_datetime,transaction_type,note,transaction_amount," .
|
|
"deleted,entered_time,entered_by_user_num) " .
|
|
"VALUES ($school_num,$user_num,$schedule_num,$order_num,$ordered_by_num,'$datetime','Late Charge','Order Entered $today',$late_charge_amount," .
|
|
"'N',$entered_time,$entered_user_num)";
|
|
db_query($query);
|
|
}
|
|
}
|
|
|
|
|
|
// Determine if there is already a tax charge for this order
|
|
$query = "SELECT * FROM user_account WHERE school_num = $school_num AND user_num = $user_num AND order_num = $order_num AND transaction_type = 'Tax Charge' AND deleted = 'N'";
|
|
$results = db_query($query);
|
|
if (!isset($tax_description)) $tax_description = '';
|
|
$tdescription = db_escape_string($tax_description) . ' - Order (#' . $order_num . ')';
|
|
|
|
|
|
// Create tax charge entry if required
|
|
if (db_num_rows($results) == 0) {
|
|
$datetime = date("Y-m-d H:i:s",time());
|
|
$entered_time = time();
|
|
$entered_user_num = intval($_SESSION['UserInfo']['record_num']);
|
|
$query = "INSERT INTO user_account (school_num,user_num,schedule_num,order_num,people_num,transaction_datetime,transaction_type,note,transaction_amount," .
|
|
"deleted,entered_time,entered_by_user_num) " .
|
|
"VALUES ($school_num,$user_num,$schedule_num,$order_num,$ordered_by_num,'$datetime','Tax Charge','$tdescription',$tax_charge_amount," .
|
|
"'N',$entered_time,$entered_user_num)";
|
|
db_query($query);
|
|
}
|
|
else {
|
|
db_query("UPDATE user_account SET transaction_amount = $tax_charge_amount,note = '$tdescription' " .
|
|
"WHERE school_num = $school_num AND user_num = $user_num AND order_num = $order_num AND transaction_type = 'Tax Charge' AND deleted = 'N'");
|
|
}
|
|
|
|
|
|
// Create additional order fee entry if required
|
|
$additional_charge = $hotlunch_schedule['additional_charge'];
|
|
$additional_charge_message = db_escape_string($hotlunch_schedule['additional_charge_message']);
|
|
if ($additional_charge > 0) {
|
|
// Determine if there is already an additional order fee for this order
|
|
$results = db_query("SELECT * FROM user_account WHERE school_num = $school_num AND user_num = $user_num AND order_num = $order_num AND transaction_type = 'Additional Order Fee' AND deleted = 'N'");
|
|
|
|
if (db_num_rows($results) == 0) {
|
|
$datetime = date("Y-m-d H:i:s",time());
|
|
$entered_time = time();
|
|
$entered_user_num = intval($_SESSION['UserInfo']['record_num']);
|
|
$query = "INSERT INTO user_account (school_num,user_num,schedule_num,order_num,people_num,transaction_datetime,transaction_type,note,transaction_amount,deleted,entered_time,entered_by_user_num) " .
|
|
"VALUES ($school_num,$user_num,$schedule_num,$order_num,$ordered_by_num,'$datetime','Additional Order Fee','$additional_charge_message',$additional_charge,'N',$entered_time,$entered_user_num)";
|
|
db_query($query);
|
|
}
|
|
}
|
|
|
|
|
|
// Process any generated charge requirements
|
|
if ($school_record['implement_generated_charge'] == 'Y') {
|
|
// Check for an existing charge
|
|
switch ($school_record['generated_charge_occurrence']) {
|
|
case 'Once':
|
|
$numGCharges = db_getVal("SELECT count(*) FROM user_account " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND user_num = $user_num " .
|
|
"AND people_num = $ordered_by_num " .
|
|
"AND transaction_type = 'Generated Charge' " .
|
|
"AND deleted != 'Y'");
|
|
break;
|
|
|
|
case 'Order':
|
|
$numGCharges = db_getVal("SELECT count(*) FROM user_account " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND user_num = $user_num " .
|
|
"AND people_num = $ordered_by_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND transaction_type = 'Generated Charge' " .
|
|
"AND deleted != 'Y'");
|
|
break;
|
|
|
|
case 'Family':
|
|
$numGCharges = db_getVal("SELECT count(*) FROM user_account " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND user_num = $user_num " .
|
|
"AND transaction_type = 'Generated Charge' " .
|
|
"AND deleted != 'Y'");
|
|
break;
|
|
}
|
|
|
|
if ($numGCharges == 0) {
|
|
$generated_charge_amount = $school_record['generated_charge_amount'];
|
|
$generated_charge_note = $school_record['generated_charge_note'];
|
|
$generated_charge_amount = floatval($generated_charge_amount);
|
|
if ($generated_charge_amount > 0) {
|
|
$query = "INSERT INTO user_account (school_num,user_num,schedule_num,order_num,people_num,transaction_datetime,transaction_type,note,transaction_amount,deleted,entered_time,entered_by_user_num) " .
|
|
"VALUES ($school_num,$user_num,$schedule_num,0,$ordered_by_num,'$datetime','Generated Charge','$generated_charge_note',$generated_charge_amount,'N',$entered_time,$entered_user_num)";
|
|
db_query($query);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Process any generated credit requirements
|
|
if ($school_record['implement_generated_credit'] == 'Y') {
|
|
// Check for an existing credit
|
|
$gcwhere = "";
|
|
if ($school_record['generated_credit_occurrence'] == 'Every Order') $gcwhere = "AND schedule_num = $schedule_num ";
|
|
$numGCredits = db_getVal("SELECT count(*) FROM user_account WHERE school_num = $school_num AND user_num = $user_num $gcwhere AND people_num = $ordered_by_num AND transaction_type = 'Generated Credit' AND deleted != 'Y'");
|
|
|
|
if ($numGCredits == 0) {
|
|
$generated_credit_amount = $school_record['generated_credit_amount'];
|
|
$generated_credit_note = $school_record['generated_credit_note'];
|
|
$generated_credit_amount = abs(floatval($generated_credit_amount)) * -1;
|
|
if ($generated_credit_amount != 0.00) {
|
|
$query = "INSERT INTO user_account (school_num,user_num,schedule_num,order_num,people_num,transaction_datetime,transaction_type,note,transaction_amount,deleted,entered_time,entered_by_user_num) " .
|
|
"VALUES ($school_num,$user_num,$schedule_num,0,$ordered_by_num,'$datetime','Generated Credit','$generated_credit_note',$generated_credit_amount,'N',$entered_time,$entered_user_num)";
|
|
db_query($query);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// Send parent an email if required
|
|
// startLog("hotlunch_orders.save.php");
|
|
writeLog("send_order_email: ".$school_record['send_order_email']);
|
|
if (isset($user_num)) writeLog("user_num: ".$user_num);
|
|
writeLog("source: ".$source);
|
|
|
|
if ($school_record['send_order_email'] != 'No' && isset($user_num) && $user_num > 0 && ($source == 'On-Line' || $school_record['send_order_email'] == 'All Orders')) {
|
|
$email_message = trim($hotlunch_schedule['email_message']);
|
|
writeLog("email_message: $email_message");
|
|
if (strlen($email_message) > 0) {
|
|
// Get parent record
|
|
$results = db_query("SELECT * FROM users WHERE school_num = $base_school_num AND record_num = $user_num");
|
|
$parent = db_fetch_array($results);
|
|
$parent_name = $parent['first_name'].' '.$parent['last_name'];
|
|
$parent_userid = $parent['userid'];
|
|
|
|
writeLog("parent_name: $parent_name");
|
|
writeLog("parent_email: ".$parent['email']);
|
|
|
|
// Get account balance
|
|
$balance = db_getVal("select sum(transaction_amount) as balance from user_account where school_num = $school_num and user_num = $user_num AND (deleted != 'Y' OR deleted IS NULL)");
|
|
writeLog("balance: $balance");
|
|
|
|
if ($school_record['status'] != 'Special' && strlen($parent['email']) > 0) {
|
|
if ($_SESSION['UserInfo']['type'] != 'SuperUser') {
|
|
include_once("include/queuemail.php");
|
|
|
|
$emailRecipient = $parent['userid'];
|
|
$emailTo = $parent['email'];
|
|
$emailReply = $school_record['reply_description'];
|
|
$emailFrom = setReplyAddress($school_record['reply_email'],"notifications");
|
|
$emailSubject = $school_record['school_name'] . " " . getLanguageText('TEXT-ORDER-DETAILS');
|
|
|
|
writeLog("emailTo: $emailTo");
|
|
writeLog("emailReply: $emailReply");
|
|
writeLog("emailFrom: $emailFrom");
|
|
|
|
$sign = "";
|
|
if ($balance < 0) $sign = "-";
|
|
$emailMessage = $hotlunch_schedule['schedule_name'] . "\n\n" .
|
|
getLanguageText('TEXT-ORDER-DETAILS') . ":\n" .
|
|
" - " . $current_name . "\n" .
|
|
" - " . getLanguageText('TEXT-ORDER-TOTAL') . ": $currencySymbol" . number_format($ordertotal,2) . "\n" .
|
|
" - " . getLanguageText('TEXT-ORDER-NUMBER') . ": $order_num\n" .
|
|
" - " . getLanguageText('TEXT-ACCOUNT-BALANCE') . ": $sign$currencySymbol" . number_format(abs($balance),2) . "\n\n" .
|
|
" - " . "$parent_name ($parent_userid)\n\n" .
|
|
$email_message;
|
|
|
|
// Send the email
|
|
writeLog("QueueEmail call");
|
|
QueueEmail($emailTo, $emailFrom, $emailSubject, $emailMessage, $emailReply, $emailRecipient);
|
|
writeLog("QueueEmail call completed");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if ($ordered_by_type != 'Concession' && strlen($hotlunch_schedule['notification_email'])) {
|
|
if ($_SESSION['UserInfo']['type'] != 'SuperUser') {
|
|
include_once("include/queuemail.php");
|
|
|
|
$emailTo = $hotlunch_schedule['notification_email'];
|
|
$emailRecipient = getLanguageText('TEXT-ORDER-NOTIFICATION');
|
|
$emailFrom = "notifications@hotlunches.net";
|
|
$emailFrom = setReplyAddress($school_record['support_email'],"notifications");
|
|
$emailReply = $school_record['school_name'];
|
|
$emailSubject = getLanguageText('TEXT-ORDER-NOTIFICATION');
|
|
|
|
$emailMessage = $hotlunch_schedule['schedule_name'] . "\n\n" .
|
|
getLanguageText('TEXT-ORDER-DETAILS') . ":\n" .
|
|
" - " . $current_name . "\n" .
|
|
" - " . getLanguageText('TEXT-ORDER-TOTAL') . ": $currencySymbol" . number_format($ordertotal,2) . "\n" .
|
|
" - " . getLanguageText('TEXT-ORDER-NUMBER') . ": $order_num\n" .
|
|
"\n\n";
|
|
if ($hotlunch_schedule['notification_order_details'] == 'Y') {
|
|
$emailMessage .= $orderItemsText .
|
|
"\n\n\n";
|
|
}
|
|
|
|
// Send the email
|
|
QueueEmail($emailTo, $emailFrom, $emailSubject, $emailMessage, $emailReply, $emailRecipient);
|
|
}
|
|
}
|
|
|
|
|
|
// Ensure the order total is correct
|
|
$calcResults = calcOrderTotal($order_num,$schedule_num,'Y');
|
|
|
|
// Update order source
|
|
if (isset($user_num) && $user_num > 0) db_query("UPDATE users SET source = '$source' where school_num = $base_school_num AND record_num = $user_num");
|
|
|
|
|
|
// Delete duplicate orders
|
|
if ($hotlunch_schedule['allow_multiple_orders'] != 'Y') {
|
|
$results = db_query("SELECT record_num FROM hotlunch_order_header " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND ordered_by_num = $ordered_by_num " .
|
|
"AND record_num != $order_num");
|
|
if (db_num_rows($results)) {
|
|
while ($row = db_fetch_array($results)) {
|
|
$onum = $row['record_num'];
|
|
logOrderChange($onum, "DUPLICATE ORDER DELETED", "hotlunch_orders.save.php");
|
|
$query = "DELETE FROM user_account " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND people_num = $ordered_by_num " .
|
|
"AND transaction_type = 'Order' " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND order_num = $onum";
|
|
db_query($query);
|
|
}
|
|
}
|
|
|
|
$query = "SELECT record_num FROM hotlunch_order_header " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND ordered_by_num = $ordered_by_num " .
|
|
"AND record_num != $order_num";
|
|
$results = db_query($query);
|
|
while ($row = db_fetch_assoc($results)) {
|
|
$rnum = $row['record_num'];
|
|
db_query("DELETE FROM hotlunch_order_header " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND ordered_by_num = $ordered_by_num " .
|
|
"AND record_num = $rnum");
|
|
}
|
|
|
|
$items = db_query("SELECT record_num FROM hotlunch_order_items " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND ordered_by_num = $ordered_by_num " .
|
|
"AND order_num != $order_num");
|
|
if (db_num_rows($items)) {
|
|
while ($row = db_fetch_assoc($items)) {
|
|
$rnum = $row['record_num'];
|
|
db_query("DELETE FROM hotlunch_order_items WHERE record_num = $rnum");
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Administration Team','Supplier');
|
|
if (checkPermission($AllowedUserTypes) == 1) {
|
|
$userid = db_getVal("select userid from users,people where users.school_num = $base_school_num and people.record_num = $ordered_by_num and people.user_num = users.record_num");
|
|
if (isset($userid) && strlen($userid) > 0) $current_name .= " / [<a href='?action=user-account&naction=add&user_num=$user_num'>$userid</a>]";
|
|
}
|
|
|
|
// Setup icon and link to edit account info
|
|
$account_icon = "<img src='images/icons/money24.png' alt='View Account Details' border='0'>";
|
|
$account_link = "<a href='?action=user-account&naction=add&user_num=$user_num' title='View Account Details'>$account_icon</a>";
|
|
|
|
// Setup icon and link to edit order
|
|
$order_icon = "<img src='images/icons/textfile24.png' alt='Edit Order' border='0'>";
|
|
$order_link = "<a href='?action=orders&naction=edit&schedule_num=$schedule_num&order_num=$order_num' title='Edit Order'>$order_icon</a>";
|
|
|
|
// Setup icon and link to edit order header
|
|
$edit_icon = "<img src='images/icons/edit24.png' alt='Edit Order Status' border='0'>";
|
|
$edit_link = "<a href='?action=orders&naction=edit-header&schedule_num=$schedule_num&order_num=$order_num'>$edit_icon</a>";
|
|
if ($_SESSION['UserInfo']['type'] != 'SuperUser') $edit_link = '';
|
|
|
|
// echo("<br>\n");
|
|
$form_message = getLanguageText('TEXT-ORDER-SAVED').": $current_name";
|
|
if ($order_status == 'Inactive') $form_message .= "<br>" . getLanguageText('MSG-ORDER-STATUS-INACTIVE');
|
|
|
|
extract($calcResults);
|
|
|
|
|
|
if (!isset($tax_description)) $tax_description = '';
|
|
if (!isset($paper_order_charge)) $paper_order_charge = '';
|
|
|
|
$link = "/?action=orders&naction=completed&schedule_num=$schedule_num&order_num=$order_num&source=$source&user_num=$user_num" .
|
|
"&ordered_by_num=$ordered_by_num&ordertotal=$ordertotal&discount_amount=$discount_amount&order_total=$order_total&late_charge_amount=$late_charge_amount" .
|
|
"&order_status=$order_status&multi_order_discount=$multi_order_discount" .
|
|
"&tax_charge_amount=$tax_charge_amount&tax_description=" . urlencode($tax_description) .
|
|
"&paper_order_charge=$paper_order_charge&edit_link=" . urlencode($edit_link) .
|
|
"&account_link=" . urlencode($account_link) .
|
|
"&order_link=" . urlencode($order_link) .
|
|
"¤t_name=" . urlencode($current_name) .
|
|
"&form_message=" . urlencode($form_message);
|
|
header("Location: $link");
|
|
exit();
|
|
|
|
?>
|