/** * Payment Stats * * Retrieve stats associated with Payments * * @return array Payment stats */ function payments_stats() { // Count payments for the current month $payments_this_month = 0; // ... and total them $total_payments_this_month = 0.0; // Get all payments for this month $now = getDate(time()); $first_of_month = mktime(0, 0, 1, $now['mon'], 1, $now['year']); try { // Iterate through the payments $paymentdbo_array = load_array_PaymentDBO("UNIX_TIMESTAMP(date) > " . $first_of_month); foreach ($paymentdbo_array as $payment) { // Add payment to totals $payments_this_month++; $total_payments_this_month += $payment->getAmount(); } } catch (DBNoRowsFoundException $e) { } return array("count" => $payments_this_month, "total" => $total_payments_this_month); }
/** * Initialize the Table * * @param array $params Parameters from the {form_table} tag */ public function init($params) { parent::init($params); // Build an Payment filter $where = ""; if (isset($this->invoiceID)) { $where = sprintf("invoiceid='%d'", $this->invoiceID); } if (isset($this->orderID)) { $where = sprintf("orderid='%d'", $this->orderID); } // Load the Payment Table try { // Build the table $items = load_array_PaymentDBO($where); foreach ($items as $dbo) { // Put the row into the table $this->data[] = array("id" => $dbo->getID(), "date" => $dbo->getDate(), "amount" => $dbo->getAmount(), "type" => $dbo->getType(), "module" => $dbo->getModule(), "status" => $dbo->getStatus()); } } catch (DBNoRowsFoundException $e) { } }
/** * Get Payment's * * @return array An array of PaymentDBO's for this order */ public function getPayments() { try { return load_array_PaymentDBO("orderid=" . $this->getID()); } catch (DBNoRowsFoundException $e) { return array(); } }
/** * Set Invoice ID * * @param integer $id Invoice ID */ function setID($id) { $this->id = $id; // Load any line-items for this Invoice try { $this->invoiceitemdbo_array = load_array_InvoiceItemDBO("invoiceid=" . intval($id)); } catch (DBNoRowsFoundException $e) { $this->invoiceitemdbo_array = array(); } // Load any payments for this Invoice try { $this->paymentdbo_array = load_array_PaymentDBO("invoiceid=" . intval($id)); } catch (DBNoRowsFoundException $e) { $this->paymentdbo_array = array(); } }
/** * Load a Paypal Payment DBO * * Searches the database for a Paypal transaction by TX id (transaction1 field) * * @param string $tx Paypal's TX ID */ function loadPaypalPaymentDBO($tx) { $DB = DBConnection::getDBConnection(); try { $paymentDBOArray = load_array_PaymentDBO(sprintf("transaction1=%s AND module=%s", $DB->quote_smart($tx), $DB->quote_smart($this->getName()))); } catch (DBNoRowsFoundException $e) { } if (count($paymentDBOArray) > 1) { fatal_error("PaypalWPS::loadPaypalPaymentDBO", "Found duplicate Paypal transactions in the database. TX = " . $tx); } return $paymentDBOArray[0]; }