Your IP : 216.73.217.117


Current Path : /var/www/cesa.co.za/php/includes/
Upload File :
Current File : /var/www/cesa.co.za/php/includes/MarketingPayments.php

<?php

/*
 * Contact otto@igotafrica.com for details
 */

include_once('BaseTableClass.php');

/**
 * Control the  MarketingPayments table
 *
 * @author Otto Saayman
 */
class MarketingPayments extends BaseTableClass {

    public function findByEventAttendeeId($eventAttendeeId) {
        return $this->sqlf->getAll("SELECT * FROM MarketingPayments WHERE MarketingPayments.AttendeeId = $eventAttendeeId");
    }

    public function markPaidByEventAttendeeId($eventAttendeeId, $amountDue, $eventId) {

        $payment = $this->findByEventAttendeeId($eventAttendeeId);

        if (!is_array($payment) || count($payment) <= 0) {
            $payment = array(
                'AttendeeID' => $eventAttendeeId,
                'AmountDue' => $amountDue,
                'AmountPaid' => $amountDue,
                'Refund' => 0,
                'AmountOStd' => 0,
                'DatePaid' => new \DateTime(),
                'Method' => '',
                'Reference' => 'Bulk Update',
                'AccountNo' => '',
                'InvoiceDate' => new \DateTime(),
                'InvoiceNo' => '',
                'StockCode' => '',
                'ReceiptNo' => '',
                'CreditNoteNo' => '',
                'CESADiscount' => 0,
                'EBDiscount' => 0,
                'AmountDep' => 0,
                'EventID' => $eventId
            );

            $this->sqlf->autoExecute('MarketingPayments', $payment, 'INSERT');
        }
    }

    public function markNotPaidByEventAttendeeId($eventAttendeeId, $amountDue, $eventId) {

        $payment = $this->findByEventAttendeeId($eventAttendeeId);

        if (is_array($payment) || count($payment) > 0) {
            $payment = array(
                'AttendeeID' => $eventAttendeeId,
                'AmountDue' => $amountDue,
                'AmountPaid' => 0,
                'Refund' => 0,
                'AmountOStd' => 0,
                'DatePaid' => new \DateTime(),
                'Method' => '',
                'Reference' => 'Bulk Update',
                'AccountNo' => '',
                'InvoiceDate' => new \DateTime(),
                'InvoiceNo' => '',
                'StockCode' => '',
                'ReceiptNo' => '',
                'CreditNoteNo' => '',
                'CESADiscount' => 0,
                'EBDiscount' => 0,
                'AmountDep' => 0,
                'EventID' => $eventId
            );

            $this->sqlf->autoExecute('MarketingPayments', $payment, 'UPDATE', 'PaymentID = ' . $payment[0]['PaymentID'], 'PaymentID');
        }
    }
}