0) { $query = "SELECT * FROM user_account WHERE school_num = $school_num AND user_num = $user_num AND deleted != 'Y' ORDER BY transaction_datetime"; $results = db_query($query); $orders = ""; $balance = 0; while ($row = db_fetch_assoc($results)) { extract($row); $balance = $balance + $transaction_amount; $ostatus = ''; if ($order_num > 0) { if (strlen($orders)) $orders .= ","; $orders .= $order_num; } if ($balance <= 0.00 && strlen($orders)) { $query = "UPDATE hotlunch_order_header SET status = 'Paid' WHERE school_num = $school_num AND record_num IN ($orders)"; db_query($query); $orders = ''; } } } $query = "SELECT u.userid,substring(transaction_datetime,1,10) as trx_date,transaction_datetime,transaction_type,note,transaction_amount,schedule_num,order_num," . "transaction_status,trx_history,payment_method,payment_reference,order_payments,ua.user_num,people_num,p.people_type,entered_by_user_num," . "p.first_name,p.last_name,p.menu_price_category,additional_note,ua.record_num " . "FROM user_account as ua LEFT JOIN people as p ON ua.people_num = p.record_num, users AS u " . "WHERE u.school_num = $base_school_num " . "AND ua.school_num IN ($snums) " . "AND ua.user_num = $user_num " . "AND ua.user_num = u.record_num " . "AND (deleted != 'Y' OR deleted IS NULL) " . "ORDER BY userid,transaction_datetime,record_num"; $transactions = db_query($query); $mode = 'account'; $print_cmd = "&selected_usernum=$user_num"; } echo("
\n"); if (in_array($_SESSION['UserInfo']['type'],array('Parent','Staff'))) { $user_num = intval($_SESSION['UserInfo']['record_num']); $user_balance = floatval(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)")); if ($user_balance < 0) { $msg = getLanguageText('TEXT-CREDIT-BALANCE'); $msg .= ":   $currencySymbol" . number_format(abs($user_balance),2); $class = 'success'; } else { $msg = getLanguageText('TEXT-BALANCE-OWING'); $msg .= ":   $currencySymbol" . number_format(abs($user_balance),2); $class = 'error'; } ?>
No Transactions Found

\n"); echo("
\n"); } else { $title = getLanguageText('TEXT-ACCOUNT-TRANSACTIONS'); if (isset($aview) && $aview == 'consolidated') $title = getLanguageText('TEXT-CONSOLIDATED-ACCOUNT-TRANSACTIONS'); ?>

1 && (!isset($view) || $view != 'details') && isset($print_cmd) && strlen($print_cmd) > 0) { ?> 0) { // Get schedule record if (isset($schedule_num) && $schedule_num > 0) { $schedule_name = ""; if (array_key_exists($schedule_num,$schoolSchedules)) { $schedule = $schoolSchedules[$schedule_num]; $sname = $schedule['schedule_name']; $schedule_name = str_replace("'","'",$sname); } } else { $sname = ""; $schedule_name = ""; } // Get the order header $results = db_query("SELECT * FROM hotlunch_order_header WHERE record_num = $order_num"); $row = db_fetch_array($results); // Get the order total $order_total = db_getVal("SELECT sum(extended_price) FROM hotlunch_order_items WHERE school_num = $school_num AND order_num = $order_num AND active = 'Y'"); // Handle any discount offered $discount_amount = 0; if ($row['source'] == 'On-Line' && $schedule['discount_offered'] > 0 && $schedule['discount_expiry_date'] >= $row['updated_date']) { $discount_offered = $schedule['discount_offered']; $discount_type = $schedule['discount_type']; $discount_order_minimum = $schedule['discount_order_minimum']; if ($order_total >= $discount_order_minimum) { if ($discount_type == 'Amount') { $discount_amount = $discount_offered; $order_total = $order_total - $discount_amount; } else { $discount_amount = $order_total * $discount_offered / 100; $order_total = $order_total - $discount_amount; } } } // Determine if there are any discounts defined for this schedule if (isset($schedule_num) && $schedule_num > 0) { $today = date("Y-m-d",time()); $numDiscounts = db_getVal("SELECT count(*) FROM hotlunch_schedules_discounts " . "WHERE school_num = $school_num " . "AND schedule_num = $schedule_num " . "AND (expiry_date IS NULL OR expiry_date >= '$today') " . "ORDER BY menu_group,order_quantity"); if ($numDiscounts > 0) { // Get the discount amount $discount_amount = db_getVal("SELECT discount_amount FROM hotlunch_order_header WHERE record_num = $order_num"); $order_total = $order_total - $discount_amount; } } // Update user account order total $order_total = sprintf("%0.2f",$order_total); db_query("UPDATE user_account SET transaction_amount = $order_total WHERE record_num = $rnum"); db_query("UPDATE hotlunch_order_header SET order_total = $order_total WHERE record_num = $order_num"); // Build the order tool tip $span_id = "order_span_$order_num"; if (!in_array($span_id,$otipSpanIDs)) { $otipSpans .= "" . $otipTABLE600 . sprintf($otipROW2,getLanguageText('TEXT-ORDER-NUMBER') . ": ",$order_num) . sprintf($otipROW2,getLanguageText('TEXT-ORDERED-FOR') . ": ",$row['ordered_by_type']); if (isset($first_name) && strlen($first_name)) { $otipSpans .= sprintf($otipROW2,getLanguageText('TEXT-NAME') . ": ","$first_name $last_name"); if (isset($menu_price_category) && strlen($menu_price_category)) $otipSpans .= sprintf($otipROW2,getLanguageText('TEXT-CATEGORY') . ": ",$menu_price_category); } $otipSpans .= sprintf($otipROW2,getLanguageText('TEXT-SCHEDULE') . ": ",$schedule_name); if ($row['discount_amount'] > 0) { $otipSpans .= sprintf($otipROW2,getLanguageText('TEXT-SUBTOTAL') . ": ",$currencySymbol . number_format($row['order_subtotal'],2)) . sprintf($otipROW2,getLanguageText('TEXT-DISCOUNT') . ": ",$currencySymbol . number_format($row['discount_amount'],2)); } $otipSpans .= sprintf($otipROW2,getLanguageText('TEXT-ORDER-TOTAL') . ": ",$currencySymbol . number_format($row['order_total'],2)) . sprintf($otipROW2,getLanguageText('TEXT-AMOUNT-PAID') . ": ",$currencySymbol . number_format($row['amount_paid'],2)). sprintf($otipROW2,getLanguageText('TEXT-STATUS') . ": ",$row['status']). sprintf($otipROW2,getLanguageText('TEXT-ORDER-DATE') . ": ",$row['added_date']) . sprintf($otipROW2,getLanguageText('TEXT-SOURCE') . ": ",$row['source']) . sprintf($otipROW2,getLanguageText('TEXT-PAYMENT-METHOD') . ": ",$row['payment_method']) . sprintf($otipROW2,getLanguageText('TEXT-UPDATED-DATE') . ": ",$row['updated_date']); if ($row['paid_date']) $otipSpans .= sprintf($otipROW2,getLanguageText('TEXT-PAID-DATE') . ": ",$row['paid_date']); if (isset($aview) && $aview == 'consolidated' && intval($row['school_num']) > 0) { $site = db_getVal("SELECT school_name FROM schools WHERE record_num = " . $row['school_num']); $otipSpans .= sprintf($otipROW2,"Site: ",$site); } $otipSpans .= sprintf($otipROW2,"TRX: ",$rnum); $otipSpans .= sprintf($otipROW2,getLanguageText('TEXT-TRANSACTION-STATUS') . ": ",$trx_status); $otipSpans .= sprintf($otipROW2,getLanguageText('TEXT-ENTERED-BY') . ": ",$row['entered_by']); $otipSpans .= "
 
\n"; $otipSpanIDs[] = $span_id; } $order_tip = " onmouseover=\"TagToTip('$span_id')\" onmouseout=\"UnTip()\""; $command = "" . ""; if ($_SESSION['UserInfo']['type'] == 'SuperUser' || $_SESSION['UserInfo']['type'] == 'System Administrator') { $msg = getLanguageText('TEXT-CONFIRM-STATUS-CHANGE'); $command = "$command " . "" . "" . " " . "" . "" . "" . "" . ""; } } else { // Build the trx tool tip $span_id = "order_span_$record_num"; if (!in_array($span_id,$otipSpanIDs)) { $otipSpans .= "" . $otipTABLE600 . sprintf($otipROW2,getLanguageText('TEXT-TRANSACTION-TYPE') . ": ",$trx_typeText) . sprintf($otipROW2,getLanguageText('TEXT-DATE') . ": ",$trx_date) . sprintf($otipROW2,getLanguageText('TEXT-TRANSACTION-NUMBER') . ": ",$record_num) . sprintf($otipROW2,getLanguageText('TEXT-TRANSACTION-NOTE') . ": ",$noteText) . sprintf($otipROW2,getLanguageText('TEXT-TRANSACTION-AMOUNT') . ": ",$currencySymbol . number_format(abs($transaction_amount),2)); $otipSpans .= sprintf($otipROW2,"TRX: ",$rnum); $dflag = ''; if (isset($deleted) && $deleted == 'Y') $dflag = " (D)"; $otipSpans .= sprintf($otipROW2,getLanguageText('TEXT-TRANSACTION-STATUS') . ": ","$trx_status$dflag"); $otipSpans .= "\n"; $otipSpanIDs[] = $span_id; } $trx_typeText = "$trx_typeText"; $command = ""; if (isset($trx_history) && strlen(trim($trx_history))) { $command .= " $filesearch_icon"; } } break; case 'Complimentary Credit': $credit = "- $currencySymbol" . number_format(abs($transaction_amount),2); $balance += $transaction_amount; $total_credits += $transaction_amount; // Build the trx tool tip $span_id = "order_span_$record_num"; if (!in_array($span_id,$otipSpanIDs)) { $otipSpans .= "" . $otipTABLE600 . sprintf($otipROW2,getLanguageText('TEXT-TRANSACTION-TYPE') . ": ",$trx_typeText) . sprintf($otipROW2,getLanguageText('TEXT-DATE') . ": ",$trx_date) . sprintf($otipROW2,getLanguageText('TEXT-TRANSACTION-NUMBER') . ": ",$record_num) . sprintf($otipROW2,getLanguageText('TEXT-TRANSACTION-NOTE') . ": ",$noteText) . sprintf($otipROW2,getLanguageText('TEXT-TRANSACTION-AMOUNT') . ": ",$currencySymbol . number_format(abs($transaction_amount),2)); $otipSpans .= sprintf($otipROW2,"TRX: ",$rnum); $otipSpans .= sprintf($otipROW2,getLanguageText('TEXT-TRANSACTION-STATUS') . ": ",$trx_status); $otipSpans .= "\n"; $otipSpanIDs[] = $span_id; } $order_tip = " onmouseover=\"TagToTip('$span_id')\" onmouseout=\"UnTip()\""; $trx_typeText = "$trx_typeText"; $command = ""; break; case 'Payment': $PPsname = ""; if (isset($schedule_num) && $schedule_num > 0) { if (array_key_exists($schedule_num,$schoolSchedules)) { $schedule = $schoolSchedules[$schedule_num]; $PPsname = $schedule['schedule_name']; $PPsname = str_replace("'","'",$PPsname); } } if ($note == 'PayPal Payment' || $note == 'PayPal Checkout Payment') { $results = db_query("SELECT * FROM user_paypal_transactions WHERE school_num = $school_num AND txn_id = '$payment_reference' AND current_year != 'N' ORDER BY posting_time"); if (db_num_rows($results)) { $span_id = "payment_$payment_reference"; if (!in_array($span_id,$otipSpanIDs)) { $otipSpans .= "" . $otipTABLE600; while ($row = db_fetch_array($results)) { $otipSpans .= sprintf($otipROW2,"Posting Time: ",$row['posting_time']) . sprintf($otipROW2,"Payment Date: ",$row['payment_date']) . sprintf($otipROW2,"Item: ",$row['item_name']) . sprintf($otipROW2,"Name: ",$row['first_name'] . ' ' . $row['last_name']) . sprintf($otipROW2,"Email: ",$row['payer_email']) . sprintf($otipROW2,"Currency: ",$row['mc_currency']) . sprintf($otipROW2,"Total: ",$row['mc_gross']) . sprintf($otipROW2,"Fee: ",$row['mc_fee']) . sprintf($otipROW2,"Payment Type: ",$row['payment_type']) . sprintf($otipROW2,"Payment Status: ",$row['payment_status']) . sprintf($otipROW2,"TRX ID: ",$row['txn_id']) . sprintf($otipROW2,"TRX Result: ",$row['posting_result']) . sprintf($otipROW2,"Posted to:",$PPsname); } $otipSpans .= sprintf($otipROW2,"TRX: ",$rnum); $otipSpans .= sprintf($otipROW2,getLanguageText('TEXT-TRANSACTION-STATUS') . ": ",$trx_status); $otipSpans .= "\n"; $otipSpanIDs[] = $span_id; } $payment_reference = "$payment_reference"; } } $Receipt = ""; if ($mode != 'lookup' && in_array($_SESSION['UserInfo']['type'],array('SuperUser','System Administrator','Application Administrator','Administration Team','Schedule Team','Financial','Financial Team'))) { $Receipt = " "; } if ($_SESSION['UserInfo']['type'] == 'Parent') { $Rlink = ""; } case 'Credit': case 'Credit Adjustment': case 'PayPal Refund': case 'Bambora Refund': default: $credit = "- $currencySymbol" . number_format(abs($transaction_amount),2); $balance += $transaction_amount; $total_credits += $transaction_amount; // Setup commands for payments and credits $command = ""; if ($payment_method != 'PayPal' || ($payment_method == 'PayPal' && strlen($payment_reference) == 0) || $_SESSION['UserInfo']['type'] == 'SuperUser') { $command = "$Receipt"; } if (($payment_method == 'PayPal' && strlen($payment_reference) == 0) && in_array($_SESSION['UserInfo']['type'],array('System Administrator','Application Administrator','Financial','Financial Team'))) { $command = ""; } // Calculate the order payment info $payments = explode('|',$order_payments); $ptotal = 0; $ptext = ""; for ($i = 0; $i < count($payments); $i++) { $p = str_replace('{','',str_replace('}','',$payments[$i])); if (strlen($p) && strpos($p, ':') > 0) { list($onum,$oamt) = explode(':',$p); if ($onum) { $oactual = 0; $results = db_query("SELECT * FROM hotlunch_order_header WHERE school_num = $school_num AND record_num = $onum"); if (db_num_rows($results) == 1) { $row = db_fetch_assoc($results); $oactual = $row['order_total']; $ptotal += $oactual; $schedule_num = $row['schedule_num']; } if (isset($schedule_num) && $schedule_num > 0) { if (array_key_exists($schedule_num,$schoolSchedules)) { $schedule = $schoolSchedules[$schedule_num]; $sname = $schedule['schedule_name']; $schedule_name = str_replace("'","'",$sname); $ptext .= sprintf($otipROW2,"Order #$onum","$currencySymbol$oactual - $schedule_name ($schedule_num)"); } } } } } // if ($people_num > 0) { // $results = db_query("SELECT * FROM people WHERE record_num = $people_num"); // } // Create payment otip $span_id = "type_$record_num"; $otipSpans .= "" . $otipTABLE600 . sprintf($otipROW2,getLanguageText('TEXT-TRANSACTION-TYPE') . ": ",$trx_typeText) . sprintf($otipROW2,getLanguageText('TEXT-DATE') . ": ",$trx_date) . sprintf($otipROW2,getLanguageText('TEXT-TRANSACTION-NUMBER') . ": ",$record_num) . sprintf($otipROW2,getLanguageText('TEXT-TRANSACTION-NOTE') . ": ",$noteText) . sprintf($otipROW2,getLanguageText('TEXT-TRANSACTION-AMOUNT') . ": ",$currencySymbol . number_format(abs($transaction_amount),2)); if (is_array($row) && array_key_exists('payment_method', $row)) $otipSpans .= sprintf($otipROW2,getLanguageText('TEXT-PAYMENT-METHOD') . ": ",translateText($row['payment_method'])); $otipSpans .= $ptext; $otipSpans .= sprintf($otipROW2,"Order Totals:",$currencySymbol.number_format($ptotal,2)); $otipSpans .= sprintf($otipROW2,"TRX: ",$rnum); $otipSpans .= sprintf($otipROW2,getLanguageText('TEXT-TRANSACTION-STATUS') . ": ",$trx_status); if (isset($entered_by_num) && $entered_by_num > 0) { $enteredBy = db_getVal("SELECT userid FROM users WHERE school_num = $base_school_num AND record_num = $entered_by_num"); $otipSpans .= sprintf($otipROW2,getLanguageText('TEXT-ENTERED-BY') . ": ",$enteredBy); } $otipSpans .= "\n"; $trx_typeText = "$trx_typeText"; if (abs($ptotal) != abs($transaction_amount)) $trx_typeText = "$trx_typeText"; break; case 'TRX Note': case 'Note': // Get schedule record if ($schedule_num > 0) { $schedule = $schoolSchedules[$schedule_num]; $sname = $schedule['schedule_name']; $noteText .= " - $sname"; } if (isset($additional_note) && strlen($additional_note)) { $span_id = "note_$record_num"; $otipSpans .= "" . $otipTABLE600 . sprintf($otipROW1,'left',$additional_note) . "\n"; $trx_typeText = "$trx_typeText"; } $command = ""; break; } // Format the current balance $balance = round($balance * 100) / 100; if ($balance < 0.00) $balance_amt = "- $currencySymbol" . number_format(abs($balance),2); else $balance_amt = $currencySymbol . number_format($balance,2); // Add userid link if the current user is admin or superuser if (in_array($_SESSION['UserInfo']['type'],array('SuperUser','System Administrator','Application Administrator'))) { // Get information for tool tip text $results = db_query("SELECT * FROM users WHERE record_num = $user_num"); $row = db_fetch_array($results); $user_num = $row['record_num']; $span_id = "user_span_$user_num"; $ouserid = $userid; $userid = htmlspecialchars_decode($userid,ENT_QUOTES); if (isset($userid) && strlen($userid) > 20) $userid = substr($userid,0,19) . "..."; if (isset($view) && $view == 'details' && $_SESSION['UserInfo']['type'] == 'SuperUser') { } else { if (!in_array($span_id,$otipSpanIDs)) { $user_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)"); $user_balance = floatval($user_balance); $bal = sprintf("%0.2f",$user_balance); db_query("UPDATE users SET balance_owing = $bal, account_balance = $bal WHERE school_num = $school_num AND record_num = $user_num"); $otipSpans .= "" . $otipTABLE600 . sprintf($otipROW2,getLanguageText('TEXT-USER-ID').": ",$row['userid']) . sprintf($otipROW2,getLanguageText('TEXT-TYPE').": ",$row['type']) . sprintf($otipROW2,getLanguageText('TEXT-NAME').": ",$row['first_name'] . ' ' . $row['last_name']) . sprintf($otipROW2,getLanguageText('TEXT-EMAIL').": ",$row['email']) . sprintf($otipROW2,getLanguageText('TEXT-PHONE').": ",$row['home_phone']) . sprintf($otipROW2,"Current Balance: ",$currencySymbol . number_format($user_balance,2)); if ($_SESSION['UserInfo']['type'] == 'SuperUser') $otipSpans .= sprintf($otipROW2,"Number: ",$row['record_num']); $otipSpans .= "\n"; $otipSpanIDs[] = $span_id; } $user_tip = " onmouseover=\"TagToTip('$span_id')\" onmouseout=\"UnTip()\""; $userid = "$userid"; } } // Add order number to Order transactions if ($transaction_type == "Order") { if ($order_num > 0) { $order_status = db_getVal("SELECT status FROM hotlunch_order_header WHERE school_num = $school_num AND record_num = $order_num"); switch ($order_status) { case 'Paid': case 'Pending': $ospan = ""; break; case 'Unpaid': $ospan = ""; break; case 'Complimentary': $ospan = ""; break; case 'Inactive': $ospan = ""; break; } switch ($_SESSION['UserInfo']['type']) { case 'Parent': $trx_typeText .= " (#$ospan$order_num)"; break; case 'Staff': $trx_typeText .= " (#$order_num)"; break; default: $trx_typeText .= " (#$ospan$order_num)"; break; } } // Add link to name if this is an Order transaction if ($people_num > 0) { if (strpos($note,"Order for") && $people_type == 'Student') { // Get information for tool tip text $results = db_query("SELECT * FROM people WHERE record_num = $people_num"); $row = db_fetch_array($results); $name = $row['first_name'] . " " . $row['last_name']; $pstatus = $row['status']; $span_id = "user_span$people_num"; if (!in_array($span_id,$otipSpanIDs)) { $otipSpans .= "" . $otipTABLE600 . sprintf($otipROW2,"Name: ",$name) . sprintf($otipROW2,"Status: ",$row['status']) . sprintf($otipROW2,"Class: ",getClassInfo($row['class_num'])) . "\n"; $otipSpanIDs[] = $span_id; } if ($pstatus == 'Inactive') $name = "$name"; $people_tip = " onmouseover=\"TagToTip('$span_id')\" onmouseout=\"UnTip()\""; $noteText = "$name ($schedule_name)"; } } } // Handle any translations if (isset($payment_method) && strlen($payment_method)) { $lcode = "CODE-" . strtoupper(str_replace(' ','-',$payment_method)); $lvalue = getLanguageText($lcode); if (isset($lvalue) && strlen($lvalue)) $payment_method = $lvalue; if (in_array($_SESSION['UserInfo']['type'],array('SuperUser','System Administrator','Application Administrator'))) { if ($payment_method != 'PayPal') $payment_method = "$payment_method"; } else { if (isset($Rlink) && strlen($Rlink)) { $payment_method = "$Rlink$payment_method"; } } } if (isset($transaction_status) && strlen($transaction_status)) $transaction_status = translateText($transaction_status); if (isset($payment_method) && strlen($payment_method)) $payment_method = translateText($payment_method); ?> " . $transaction_status) ?>   Posted to Schedule:
 
"; ?>   ::   ::     0) { ?>



: