コード例 #1
0
ファイル: mainHandler.php プロジェクト: haus/CoMET
                     if (addOwner($_SESSION['cardNo'], $i, $first, $last, $_POST['discount'][$i], $_POST['memType'][$i], $_POST['staff'][$i], isset($_POST['charge'][$i]) && $_POST['charge'][$i] == 'on' ? 1 : 0, isset($_POST['checks'][$i]) && $_POST['checks'][$i] == 'on' ? 1 : 0, $_SESSION['userID'])) {
                         echo ' "message": "success ' . $i . ' added ", ';
                     } else {
                         echo ' "errorMsg": "error ' . $i . ' error ", ';
                     }
                 } elseif ($ownerNumRows1 == 1 && $ownerNumRows == 0 && empty($first) && empty($last)) {
                     // Removing person from card
                     if (deleteOwner($_SESSION['cardNo'], $i)) {
                         echo ' "message": "success ' . $i . ' removed", ';
                     } else {
                         echo ' "errorMsg": "failure ' . $i . ' removed", ';
                     }
                 } elseif ($ownerNumRows1 == 1 && $ownerNumRows == 0 && !empty($first) && !empty($last)) {
                     // Updating person on card
                     // Update
                     if (updateOwner($_SESSION['cardNo'], $i, $first, $last, $_POST['discount'][$i], isset($_POST['memType'][$i]) ? escapeData($DBS['comet'], $_POST['memType'][$i]) : 0, isset($_POST['staff'][$i]) ? escapeData($DBS['comet'], $_POST['staff'][$i]) : 0, isset($_POST['charge'][$i]) && $_POST['charge'][$i] == 'on' ? 1 : 0, isset($_POST['checks'][$i]) && $_POST['checks'][$i] == 'on' ? 1 : 0, $_SESSION['userID'])) {
                         echo ' "message": "success ' . $i . ' inserted", ';
                     } else {
                         echo ' "message": "failure on ' . $i . ' inserted", ';
                     }
                 }
             }
         } else {
             // Partially filled in. Error.
             echo ' "errorMsg": "Partially Filled In" }';
             exit;
         }
     } else {
         echo ' "message": "More than one record. Database error.", ';
     }
 }
コード例 #2
0
ファイル: paymentHandler.php プロジェクト: haus/CoMET
 } else {
     // If not fully paid, subscriber
     $newMemType = 2;
 }
 $selectQ = "SELECT personNum, memType, staff\n\t\t\t\t\tFROM owners\n\t\t\t\t\tWHERE cardNo = {$_SESSION['cardNo']}";
 $selectR = mysqli_query($DBS['comet'], $selectQ);
 while (list($personNum, $memType, $staff) = mysqli_fetch_row($selectR)) {
     if ($staff == 0 || $staff == 2 || $staff == 3 || $staff == 6) {
         $newDisc = 2;
     } elseif ($staff == 1 || $staff == 4 || $staff == 5) {
         $newDisc = 15;
     } else {
         $newDisc = 0;
     }
     if ($memType != 6 && $memType != 7) {
         if (!updateOwner($_SESSION['cardNo'], $personNum, NULL, NULL, $newDisc, $newMemType, NULL, NULL, NULL, $_SESSION['userID'])) {
             echo '{ "errorMsg": "failure on ' . $personNum . ' inserted" }';
         }
     }
 }
 // Then update the details.
 // Payment Plans Update
 $planQ = sprintf("SELECT planID FROM paymentPlans WHERE amount=%s LIMIT 1", $amount);
 $planR = mysqli_query($DBS['comet'], $planQ);
 if (mysqli_num_rows($planR) > 0) {
     list($plan) = mysqli_fetch_row($planR);
 } else {
     $plan = $_SESSION['defaultPlan'];
 }
 // Next Payment Logic
 if ($amount >= 30) {
コード例 #3
0
ファイル: updates.php プロジェクト: haus/CoMET
// Move to memtype of 5. Update discount, check for staff of 1 or 5.
$onHoldQ = sprintf("SELECT d.cardNo, o.personNum, o.staff\n\tFROM owners AS o \n\t\tINNER JOIN details AS d ON o.cardNo = d.cardNo \n\tWHERE TIMESTAMPDIFF(DAY, d.nextPayment, curdate()) BETWEEN 30 AND %u \n\t\tAND o.memType IN (1, 2)", $_SESSION['inactiveDays'] - 1);
$onHoldR = mysqli_query($DBS['comet'], $onHoldQ);
if (!$onHoldR) {
    printf('Error: %s, Query: %s', mysqli_error($DBS['comet']), $onHoldQ);
}
echo 'On Hold' . "\n";
while (list($cardNo, $personNum, $staff) = mysqli_fetch_row($onHoldR)) {
    $newDisc = $staff == 1 || $staff == 5 ? 15 : 0;
    if (updateOwner($cardNo, $personNum, NULL, NULL, $newDisc, 5, NULL, NULL, NULL, $_SESSION['userID'])) {
        echo "Success: {$cardNo} - {$personNum} - {$staff} - {$newDisc} Updated\n";
    } else {
        printf("Error: %s\n", mysqli_error($DBS['comet']));
    }
}
// Then inactives...owners who will be made inactive...
// Move to memtype of 3. Update discount, check for staff of 1 or 5.
$inactiveQ = sprintf("SELECT d.cardNo, o.personNum, o.staff\n\tFROM owners AS o \n\t\tINNER JOIN details AS d ON o.cardNo = d.cardNo\n\tWHERE TIMESTAMPDIFF(DAY, d.nextPayment, curdate()) >= %u\n\t\tAND o.memType IN (1, 2, 5)", $_SESSION['inactiveDays']);
$inactiveR = mysqli_query($DBS['comet'], $inactiveQ);
if (!$inactiveR) {
    printf('Error: %s, Query: %s', mysqli_error($DBS['comet']), $inactiveQ);
}
echo 'Inactive' . "\n";
while (list($cardNo, $personNum, $staff) = mysqli_fetch_row($inactiveR)) {
    $newDisc = $staff == 1 || $staff == 5 ? 15 : 0;
    if (updateOwner($cardNo, $personNum, NULL, NULL, $newDisc, 3, NULL, NULL, NULL, $_SESSION['userID'])) {
        echo "Success: {$cardNo} - {$personNum} - {$staff} - {$newDisc} Updated\n";
    } else {
        printf("Error: %s\n", mysqli_error($DBS['comet']));
    }
}