Example #1
0
function UpdateName($connection, $ghin, $name)
{
    $player = GetPlayerDues($connection, $ghin);
    if (empty($player)) {
        return;
    }
    $sqlCmd = "UPDATE `Dues` SET `Name`= ? WHERE `GHIN` = ?";
    $update = $connection->prepare($sqlCmd);
    if (!$update) {
        die($sqlCmd . " prepare failed: " . $connection->error);
    }
    if (!$update->bind_param('si', $name, $ghin)) {
        die($sqlCmd . " bind_param failed: " . $connection->error);
    }
    if (!$update->execute()) {
        die($sqlCmd . " execute failed: " . $connection->error);
    }
    $update->close();
}
Example #2
0
<?php

require_once realpath($_SERVER["DOCUMENT_ROOT"]) . '/login.php';
require_once realpath($_SERVER["DOCUMENT_ROOT"]) . $script_folder . '/dues_functions.php';
date_default_timezone_set('America/Los_Angeles');
$ghin = $_POST['GHIN'];
if (empty($ghin)) {
    die("Which GHIN number?");
}
$connection = new mysqli('p:' . $db_hostname, $db_username, $db_password, $db_database);
if ($connection->connect_error) {
    die($connection->connect_error);
}
$player = GetPlayerDues($connection, $ghin);
if (empty($player)) {
    $player = new Dues();
    $player->GHIN = 0;
    $player->Payment = 0;
}
echo json_encode($player);
$connection->close();
Example #3
0
function UpdateDuesDatabase($connection, $ghin, $payment, $payerName, $payerEmail, $logMessage)
{
    if (!file_exists('./logs')) {
        mkdir('./logs', 0755, true);
    }
    $now = new DateTime("now");
    $year = $now->format('Y') + 1;
    $logFile = "./logs/dues." . $year . ".log";
    error_log(date('[Y-m-d H:i e] ') . $logMessage . PHP_EOL, 3, $logFile);
    if ($connection->connect_error) {
        error_log(date('[Y-m-d H:i e] ') . $connection->connect_error . PHP_EOL, 3, $logFile);
        return;
    }
    $player = GetPlayerDues($connection, $ghin);
    if (empty($player)) {
        error_log(date('[Y-m-d H:i e] ') . "Failed to find ghin " . $ghin . " in the dues table." . PHP_EOL, 3, $logFile);
        return;
    }
    // Add to the current amount to handle the refund case
    $payment = $payment + $player->Payment;
    // Duplicate the code here so the die messages can be replace with log messages
    $sqlCmd = "UPDATE `Dues` SET `Payment`= ?, `PaymentDateTime`= ?, `PayerName`= ?, `PayerEmail`= ?, `RIGS` = 0 WHERE `GHIN` = ?";
    $update = $connection->prepare($sqlCmd);
    if (!$update) {
        error_log(date('[Y-m-d H:i e] ') . $sqlCmd . " prepare failed: " . $connection->error . PHP_EOL, 3, $logFile);
        return;
    }
    $date = date('Y-m-d H:i:s');
    if (!$update->bind_param('dsssi', $payment, $date, $payerName, $payerEmail, $ghin)) {
        error_log(date('[Y-m-d H:i e] ') . $sqlCmd . " bind_param failed: " . $connection->error . PHP_EOL, 3, $logFile);
        return;
    }
    if (!$update->execute()) {
        error_log(date('[Y-m-d H:i e] ') . $sqlCmd . " execute failed: " . $connection->error . PHP_EOL, 3, $logFile);
        return;
    }
    $update->close();
    error_log(date('[Y-m-d H:i e] ') . "Updated player " . $player->Name . " payment to " . $payment . PHP_EOL, 3, $logFile);
}
Example #4
0
 // remove any slashes before quotes
 $LastName = str_replace("'", "", $LastName);
 // remove single quotes
 // Check that both GHIN and Last Name were filled in
 if (empty($GHIN) && empty($LastName)) {
     $error = 'GHIN and Last Name must be filled in';
 } else {
     if (!empty($GHIN) && empty($LastName)) {
         $error = 'Last Name must be filled in';
     } else {
         if (empty($GHIN) && !empty($LastName)) {
             $error = 'GHIN must be filled in';
         } else {
             if (!empty($GHIN) && !empty($LastName)) {
                 // TODO: Check for player already paid (may be in table but not yet paid)
                 $playerDues = GetPlayerDues($connection, $GHIN);
                 if (!empty($playerDues) && $playerDues->Payment > 0) {
                     $error = 'Player ' . $LastName . ' (' . $GHIN . ') has already payed dues';
                 } else {
                     // Check that last name matches GHIN database
                     $rosterEntry = GetRosterEntry($connection, $GHIN);
                     if (empty($rosterEntry)) {
                         $error = 'GHIN ' . $GHIN . " is not a member of the Coronado Men's Golf Club";
                     } else {
                         if (strcasecmp($LastName, $rosterEntry->LastName) != 0) {
                             $error = 'Last name for GHIN ' . $GHIN . ' is not ' . $LastName;
                         } else {
                             if (!$rosterEntry->Active) {
                                 $error = 'GHIN ' . $GHIN . " is not an active member of the Coronado Men's Golf Club";
                             } else {
                                 // Use the database casing for the last name