First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
$ValidAccess = 2010;
|
||||
require_once("include/globals.php");
|
||||
|
||||
|
||||
// Set default timezone
|
||||
date_default_timezone_set("Canada/Pacific");
|
||||
$now = date("Y-m-d H:i:s",time());
|
||||
|
||||
|
||||
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
||||
logExit("Session is not active",$moduleName);
|
||||
exit();
|
||||
}
|
||||
|
||||
// Ensure that only valid user types have access to this module
|
||||
$AllowedUserTypes = array('SuperUser');
|
||||
if (checkPermission($AllowedUserTypes) != 1) {
|
||||
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
||||
logExit($error_message);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
// CSRF token validation
|
||||
include "include/ajax.csrfToken.php";
|
||||
|
||||
|
||||
$moduleName = "ajax.PostEZS.php";
|
||||
// startLog($moduleName);
|
||||
|
||||
|
||||
$return_data = array();
|
||||
|
||||
// Get parameters
|
||||
$school_num = intval($_GET['school_num']);
|
||||
$invoice_num = intval($_GET['invoice_num']);
|
||||
|
||||
// Ensure parameters are valid
|
||||
|
||||
if (!is_numeric($school_num)) logExit("School num is not numeric");
|
||||
if (!is_numeric($invoice_num)) logExit("Invoice num is not numeric");
|
||||
if ($school_num == 0) logExit("school_num is zero");
|
||||
|
||||
writeLog("school_num: $school_num");
|
||||
writeLog("invoice_num: $invoice_num");
|
||||
|
||||
|
||||
// Get school name
|
||||
$query = "SELECT * FROM schools WHERE record_num = $school_num";
|
||||
writeLog("query: $query");
|
||||
$results = db_query($query);
|
||||
$school = db_fetch_assoc($results);
|
||||
$school_name = $school['school_name'];
|
||||
$currency = 'CAD';
|
||||
if ($school['country'] == 'USA') $currency = 'USD';
|
||||
|
||||
|
||||
// Get invoice record
|
||||
$query = "SELECT * FROM invoice_header WHERE school_num = $school_num AND record_num = $invoice_num";
|
||||
writeLog("query: $query");
|
||||
$results = db_query($query);
|
||||
$invoice = db_fetch_assoc($results);
|
||||
|
||||
|
||||
$db_host = "polarbear2";
|
||||
$db_dbname = "schoolappointments";
|
||||
$db_uname = "ezssoftwaredb";
|
||||
$db_pass = "ezs7785422700@@";
|
||||
|
||||
|
||||
writeLog("db_uname: $db_uname");
|
||||
writeLog("db_pass: $db_pass");
|
||||
|
||||
db_close($_DB);
|
||||
db_connect($db_host,$db_uname,$db_pass,$db_dbname);
|
||||
|
||||
db_query("SET NAMES utf8");
|
||||
db_query("SET CHARACTER SET utf8");
|
||||
|
||||
db_query("USE schoolappointments");
|
||||
|
||||
|
||||
$payments = new Table("invoice_payments");
|
||||
|
||||
$note = $school_name;
|
||||
$application = "Hot Lunches";
|
||||
$invoice_subtotal = $invoice['subtotal'];
|
||||
$invoice_gst = $invoice['gst'];
|
||||
$invoice_total = $invoice['total'];
|
||||
$entered = time();
|
||||
$payment_date = date("Y-m-d",$entered);
|
||||
$amount = $invoice_total;
|
||||
$group_with_next = 'N';
|
||||
$batch_num = 0;
|
||||
$company = 'EZS Software';
|
||||
$original_batch_num = 0;
|
||||
|
||||
$entry = array();
|
||||
if (isset($school_num)) $entry['school_num'] = $school_num;
|
||||
if (isset($note)) $entry['note'] = $note;
|
||||
if (isset($invoice_num)) $entry['invoice_num'] = $invoice_num;
|
||||
if (isset($application)) $entry['application'] = $application;
|
||||
if (isset($invoice_subtotal)) $entry['invoice_subtotal'] = $invoice_subtotal;
|
||||
if (isset($invoice_gst)) $entry['invoice_gst'] = $invoice_gst;
|
||||
if (isset($invoice_total)) $entry['invoice_total'] = $invoice_total;
|
||||
if (isset($payment_date)) $entry['payment_date'] = $payment_date;
|
||||
if (isset($entered)) $entry['entered'] = $entered;
|
||||
if (isset($amount)) $entry['amount'] = $amount;
|
||||
if (isset($currency)) $entry['currency'] = $currency;
|
||||
if (isset($group_with_next)) $entry['group_with_next'] = $group_with_next;
|
||||
if (isset($batch_num)) $entry['batch_num'] = $batch_num;
|
||||
if (isset($batch_closed_date)) $entry['batch_closed_date'] = $batch_closed_date;
|
||||
if (isset($original_batch_num)) $entry['original_batch_num'] = $original_batch_num;
|
||||
if (isset($company)) $entry['company'] = $company;
|
||||
|
||||
|
||||
$query = $payments->BuildInsert($entry);
|
||||
writeLog("query: $query");
|
||||
db_query($query);
|
||||
|
||||
// Check for an open batch
|
||||
$batch_message = "";
|
||||
$numOpen = db_getVal("SELECT count(*) FROM invoice_payments WHERE batch_num = 0");
|
||||
if ($numOpen > 0) {
|
||||
$amount = db_getVal("SELECT sum(amount) FROM invoice_payments WHERE batch_num = 0");
|
||||
$batch_message = "There is an Open Batch with $numOpen Cheques - $currencySymbol".number_format($amount,2);
|
||||
}
|
||||
|
||||
$return_data['form_message'] = $batch_message;
|
||||
|
||||
echo(json_encode($return_data));
|
||||
writeLog("completed");
|
||||
return(0);
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user