BuildInsert($parameters); writeLog("query: $query\n"); db_query($query); $record_num = db_insert_id(); } else { $query = $table->BuildUpdate($parameters); writeLog("query: $query\n"); db_query($query); // Update all orders to status paid if there is a credit if ($table_name == 'hotlunch_order_header' && isset($UpdateAll) && $UpdateAll == 'Yes') { $query = "SELECT ordered_by_num FROM hotlunch_order_header WHERE school_num = $school_num AND record_num = $record_num"; $ordered_by = db_getVal($query); if ($ordered_by > 0) { $query = "SELECT user_num FROM people WHERE school_num = $school_num AND record_num = $ordered_by"; $user_num = db_getVal($query); if ($user_num > 0) { $results = db_query("SELECT * FROM people WHERE school_num = $school_num AND user_num = $user_num"); if (db_num_rows($results)) { while ($row = db_fetch_assoc($results)) { $ordered_by .= "," . $row['record_num']; } } // Update all orders to Paid status $query = "UPDATE hotlunch_order_header SET amount_paid = order_total, payment_method = '$payment_method', paid_date = '$paid_date', status = 'Paid' " . "WHERE school_num = $school_num " . "AND status IN ('Unpaid','Inactive') " . "AND ordered_by_num IN ($ordered_by)"; db_query($query); // Update all user transactions to Closed status $query = "UPDATE user_account SET transaction_status = 'Closed' WHERE school_num = $school_num AND user_num = $user_num"; db_query($query); } } } // Update orders if payment method is being updated if ($table_name == 'user_account' && isset($action) && $action == 'edit-payment-method') { } } writeLog("complete\n"); $return_data["record_num"] = $record_num; echo(json_encode($return_data)); ?>