classes/php5_classes/Invoice.class.php

Properties

Description

Holds the geoInvoice class.

Classes

geoInvoice

Properties

 
 
System  
No 
No 

Description

This is the invoice object representing an invoice in the system.
In the grand scheme of things, there is 1 invoice attached to an order. It is actually "coded" to allow multiple invoices to be attached to a single order, but that functionality has not been fully implemented or tested, and will not be until there is an actual reason to use that functionality. An invoice can have multiple transactions {@link geoTransaction} attached to it. The "invoice total" is calculated by adding up the amounts on all active transactions attached to the invoice. If the balance is negative, that means the buyer owes the seller money. If the balance is positive, that means the seller owes the buyer money, but that part is not accounted for in the system, when that is the case, most of the time it is treated as if the balance is 0 meaning the buyer has paid the seller and nothing more is owed.

Methods

__construct, addTransaction, detachTransaction, detailsArray, get, getBillingInfo, getCreated, getDue, getId, getInvoice, getInvoiceLink, getInvoiceTotal, getOrder, getParent, getTransaction, getUser, remove, render, save, serialize, set, setBillingInfo, setCreated, setDue, setId, setOrder, setParent, setTransaction, touch, unSerialize,

__construct( ) : n/a

Description

Constructor, initializes stuff.

Return value

Type Description
n/a n/a

addTransaction( \geoTransaction   $transaction, ) : boolean

Description

Adds a transaction to this invoice. The transaction CAN be not serialized yet, if that is the case it will be added to the new array inside of the transactions array.

Arguments

Name Type Description Default
$transaction \geoTransaction

Return value

Type Description
boolean true if add was successful, false otherwise.

detachTransaction( int   $transaction_id, ) : n/a

Description

Detaches a transaction from this invoice object.

Arguments

Name Type Description Default
$transaction_id int

Return value

Type Description
n/a n/a

detailsArray( ) : array

Description

Gets details of this invoice in an associative array, including details about things attached to this invoice like transactions. Suitable for using to display info in a template.

Return value

Type Description
array Keys of the array: order_id, invoice_id, order_amount, invoice_amount, pay_amount (amount a user must pay to pay off the amount due), invoice_date, invoice_due_date, company_address, client (associative array of user details, fields are NOT cleaned from DB), transactions (arrays of each transaction details)

get( string   $item, mixed   $default = false, ) : Mixed

Description

Gets the specified item from the registry, or if item is one of the "main" items it gets that instead.

Arguments

Name Type Description Default
$item string
$default mixed

What to return if the item is not set.

false

Return value

Type Description
Mixed the specified item, or false if item is not found.

getBillingInfo( ) : array

Description

Gets the billing info previously set using {@link geoInvoice::setBillingInfo()}
If no info, returns empty array.

Return value

Type Description
array

Tags

Name Description
since Version 4.0.5

getCreated( ) : int

Description

Get the creation date for this invoice

Return value

Type Description
int unix timestamp

getDue( ) : int

Description

Get the due date for this invoice

Return value

Type Description
int unix timestamp

getId( ) : int

Description

Gets the id for this transaction, or 0 if this is a new transaction that has not been saved yet

Return value

Type Description
int

getInvoice( int   $id, ) : \geoInvoice

Description

Gets the invoice specified by the ID and returns the geoInvoice object for that invoice, or a new blank invoice if the id is 0 or not a valid ID.
Should be called statically (like geoInvoice::getInvoice($id) )

Arguments

Name Type Description Default
$id int

If 0 or invalid ID, Object returned is for a new blank invoice.

Return value

Type Description
\geoInvoice

getInvoiceLink( int   $invoiceId, bool   $inEmail = false, bool   $inAdmin = false, ) : string

Description

Get the invoice link URL for the given invoice ID (does not check for valid invoice ID).

Arguments

Name Type Description Default
$invoiceId int

The invoice ID to get the the link for.

$inEmail bool

If true, will include full link including domain, and will not use html entities.

false
$inAdmin bool

If true, will use link usable from the admin panel.

false

Return value

Type Description
string

Tags

Name Description
since Version 6.0.0

getInvoiceTotal( ) : float

Description

Adds up the amount of all active transactions currently attached to the invoice, to get the invoice balance. A negative amount indicates that the buyer still owes the seller money.

Return value

Type Description
float

getOrder( ) : \geoOrder

Description

Get the order this invoice is attached to

Return value

Type Description
\geoOrder

getParent( ) : \geoInvoice

Description

Not used yet, this can be used in the future to make heirarchy of invoices for an order, if that is needed.

Return value

Type Description
\geoInvoice

getTransaction( int   $id = 0, ) : \geoTransaction|\array(geoTransaction)

Description

Gets a transaction object attached to this invoice, specified by the ID, or an array of all the transaction objects attached to this invoice if no ID is specified.

Arguments

Name Type Description Default
$id int 0

Return value

Type Description
\geoTransaction|\array(geoTransaction) object if ID is valid, or array of all transaction objects if id is 0, or null if id is not valid.

getUser( ) : int

Description

Gets the user ID, either from the order (if the order still exists) or from the first transaction that has the user set. Returns 0 if user cannot be found.

Return value

Type Description
int User Id

Tags

Name Description
since Version 7.3.4

remove( int   $id, bool   $remove_attached = true, ) : n/a

Description

Static function that removes an invoice as specified by ID, and also recursively removes everything attached to it. (this includes child invoices, transactions, etc).
If the invoice no longer exists, but there are still "ghost" items attached to this invoice, this function will remove those ghost items.

Arguments

Name Type Description Default
$id int
$remove_attached bool

if false, it will not remove stuff attached to this order.

true

Return value

Type Description
n/a n/a

render( bool   $showOrderDetails = true, bool   $printPage = false, ) : bool

Description

Sets up the view class to be displayed (by setting mainbody template and vars), but does NOT do the final step of actually displaying the page or setting the page ID, those should be done outside of this method, if this method returns true. The normal page ID for displaying invoice is 183.

Arguments

Name Type Description Default
$showOrderDetails bool

if true, displays the order info (if available) at the bottom of the page. Note that some of the order text will be from page #10202 (retrieved automatically if needed). If the order is no longer available, will fall back and still render invoice, but without order details section (new behavior as of Version 7.3.4).

true
$printPage bool

Not implemented yet, but once it is added, if true it will display a print friendly page, by using a generic overall template for the entire page so that the invoice is the only thing on the page (that is the plan anyways)

false

Return value

Type Description
bool True if successful and page ready to be displayed, false otherwise

save( ) : n/a

Description

Alias of geoInvoice::serialize() - see that method for details.

Return value

Type Description
n/a n/a

serialize( ) : n/a

Description

Serializes the current invoice (saves changes in the database, or creates new invoice if the id is not set. If it is a new invoice, it will set the invoice ID after it has been inserted into the database.
Also automatically serializes any objects attached to it that are not already serialized.

Return value

Type Description
n/a n/a

set( string   $item, mixed   $value, ) : n/a

Description

Sets the given item to the given value. If item is one of built-in items, it sets that instead of something from the registry.

Arguments

Name Type Description Default
$item string
$value mixed

Return value

Type Description
n/a n/a

setBillingInfo( array   $info, ) : bool

Description

Sets the billing info according to an array of data. Will only set data using keys of specific names (to prevent accidentally saving CC or other sensitive data un-encrypted in the DB):
firstname, lastname, address, address_2, city, country, state, zip, phone, email, payment_type

Arguments

Name Type Description Default
$info array

Return value

Type Description
bool True if saving info succeeded, false if something went wrong or data passed in didn't contain any savable info

Tags

Name Description
since Version 4.0.5

setCreated( int   $val, ) : n/a

Description

Set the creation date for this invoice

Arguments

Name Type Description Default
$val int

unix timestamp

Return value

Type Description
n/a n/a

setDue( int   $val, ) : n/a

Description

Set the due date for this invoice

Arguments

Name Type Description Default
$val int

unix timestamp

Return value

Type Description
n/a n/a

setId( int   $val, ) : n/a

Description

Sets the id for this invoice, using internally only.

Arguments

Name Type Description Default
$val int

Return value

Type Description
n/a n/a

setOrder( \geoOrder|int   $val, ) : n/a

Description

Set the order this invoice is attached to.

Arguments

Name Type Description Default
$val \geoOrder|int

Int id or object of the order

Return value

Type Description
n/a n/a

setParent( mixed   $val, ) : n/a

Description

Set the parent invoice (not used much yet)

Arguments

Name Type Description Default
$val mixed

Return value

Type Description
n/a n/a

setTransaction( int   $id,   $value, ) : n/a

Description

Attaches a transaction that already exists to this invoice, given the transaction's ID. Requires an ID to set. If there is no ID yet, use geoInvoice::addTransaction() instead.
This method cannot be used to add new transactions that do not have an ID yet.

Arguments

Name Type Description Default
$id int
$value n/a

Return value

Type Description
n/a n/a

touch( ) : n/a

Description

Use when this object, or one of it's child objects, has been changed, so that when it is serialized, it will know there are changes that need to be serialized.
This also recursevly touches all "parent" objects that this one is attached to. Note that this is automatically called internally when any of the set functions are used.

Return value

Type Description
n/a n/a

unSerialize( int   $id = 0, ) : n/a

Description

Unserializes the object for the given ID and applies parameters to this object.

Arguments

Name Type Description Default
$id int 0

Return value

Type Description
n/a n/a

Properties

$_pendingChanges, $created, $due, $id, $invoices, $order, $parent, $registry, $transactions, $user_id,

boolean  private  $_pendingChanges =

Used internally to remember whether there has been changes to the order since it was last serialized. If there is not changes, when serialize is called, nothing will be done.


int  private  $created =

Date this order was created.

unix timestamp




int  private  $due =

Date this order is due

unix timestamp




int  private  $id =

ID of invoice


array  private  static $invoices =

Static array of all the invoices that have been created or retrieved during this session.


\geoOrder  private  $order =

Order this invoice is attached to


\geoInvoice  private  $parent =

Not used (yet), this allows there to be heiarchy of invoices for a single order to make it easy to add functionality later.

object




array  private  $registry =

Array of settings to handle all the "misc" stuff for this order item.


array  private  $transactions =

Array of transaction objects attached to this invoice


int  private  $user_id =

User ID (not saved for the invoice itself, just stored if retrieved from order or from user)


Documentation was generated by phpDocumentor 2.2.0 .

Namespaces

  • global

    Packages

    • Default
      • ExampleAddon
        • addon_example_admin
          In charge of doing stuff on the admin side, this is optional.
        • addon_example_info
          Required class for addons, this is the Addon information class, used by the addon system to determine what the addon can do. Also contains info about the addon that can be viewed in the addon management page in the admin.
        • addon_example_pages
          Addon page class, used by the addon system to display pages on the client side.
        • addon_example_setup
          This class is not required. If it, and the function for a particular routine exist, then that function will be called IN ADDITION TO the automated routines of the addon framework.
        • addon_example_tags
          Expects one function for each tag. Function name should be the same as the tag name. Can also have a constructor if anything needs to be constructed.
        • addon_example_util
          This is where to put functions that the main part of the addon will use.
        • eWidgetOrderItem
          This order item is designed to allow users on your site to purchase an eWidget.
      • System
        • DataAccess
          This is the main Database access object.
        • Singleton
          Singleton method class
        • _templateOrderItem
          Developers: use this file as a template to create a new order item.
        • _templatePaymentGateway
          This is the "developer template" payment gateway handler, a developer could use this file as a starting point for creating a new payment gateway in the system.
        • geoAPI
          The main system class for receiving and handling remote API calls, this acts as a translation layer between the communication with the "outside" and each API call.
        • geoAddon
          This is the class that handles anything and everything to do with addons.
        • geoArrayTools
          Utility functions for manipulating arrays
        • geoBrowse
          Contains functions common to browsing listings
        • geoBrowsingFilter
          System for activating, storing, and deactivating browsing filters.
        • geoCJAX
          Class that wraps the CJAX_FRAMEWORK, used to get the CJAX class.
        • geoCache
          This is the main part of the Geo cache system, it does all the "low level" stuff like writing files and escaping cache data.
        • geoCacheModule
          Part of Geo Cache system, specifically tuned to work best with cacheing module data (which will be an array).
        • geoCachePage
          Cache system specifically tuned to work best with cacheing output of pages and modules
        • geoCacheSetting
          Part of Geo Cache system, specifically tuned to work best with cacheing site-wide key=value type settings.
        • geoCacheText
          Part of Geo Cache system, this part specifically tuned to work best with cacheing language specific messages.
        • geoCalendar
          Holds utility method(s) for manipulating stuff dealing with calendar selector.
        • geoCart
          This class is behind the cart, loading all the order items and such and displaying, and processing all the different pages.
        • geoCategory
          Utility class that holds various methods to do stuff with categories in the system.
        • geoCombineResources
          This class helps to combine CSS and JS files, minify them, and optionally compress them.
        • geoCron
          This is the cron job backend, it handles all the communication and security and all that.
        • geoCrypt
          Class to use for encrypting information that needs to be able to be retrieved later.
        • geoDate
          Holds utility method(s) for manipulating stuff dealing with dates.
        • geoEmail
          Class that sends out e-mails.
        • geoFields
          Class that holds settings information for fields to use.
        • geoFieldsField
          A mini object to hold data about a specific field.
        • geoFile
          As the name implies, this is used for file-based utility methods.
        • geoFilter
          A few utility methods, good for filtering stuff.
        • geoFormatString
          Used to display a message nice and pretty, we'll probably be getting rid of this class though so don't go crazy using it.
        • geoHTML
          Class to generate chunks of HTML that are very common, used the most in the admin panel.
        • geoImage
          This class is responsible for a lot of the image processing, along with other aspects like generating the image tag for thumbnails.
        • geoInvoice
          This is the invoice object representing an invoice in the system.
        • geoLeveledField
          Class for doing common things with leveled fields.
        • geoListing
          A listing object, basically a container object for particular listing.
        • geoListingDisplay
          This is basically a container that is responsible for helping to display {listing .
        • geoListingFeed
          Class that helps to render RSS or other types of feeds based on list of listings.
        • geoMaster
          This is dedicated class for getting the value of, and setting, the various "master switches" within the software. Since this is meant as an easy way to get the values of master switches, most of the methods are static.
        • geoNumber
          Utility functions relating to number conversion/manipulation/validation ect.
        • geoOrder
          The geoOrder object, an object representation of an order in the system.
        • geoOrderItem
          The class that all order items must extend.
        • geoPC
          Used for login credential validation, password hashing, etc. along with software licensing.
        • geoPagination
          Utility functions useful for generating pagination of a results page such as when browing ads or searching
        • geoPaymentGateway
          This class should be extended by each different payment gateway, this will have some default functions that each gateway will inherit, and also has a few final static methods used by the system to affect all order items.
        • geoPlanItem
          A container to hold settings for a particular order item type, according to price plan ID, and optionally category ID for category specific settings.
        • geoRecurringBilling
          The geoRecurringBilling object, an object representation of a recurring billing in the system.
        • geoRegion
          Stuff for regions and sub-regions.
        • geoRegistry
          Handy little object, can be used to set registry type settings.
        • geoSearchUtils
          Class for search utilities.
        • geoSellerBuyer
          Handles back-end for the seller/buyer payment gateways, to allow the buyer to more easily pay the seller for a won auction. This handles the underlying system, but the actual work is done by individual seller/buyer gateways, for instance the Paypal buy-now functionality.
        • geoSession
          Manages session storage and session cookies for user sessions.
        • geoString
          Utility functions relating to languages and string manipulation.
        • geoStringData
          This class is to store accented chars, to be used by {@link geoString::removeAccents()}, mainly to keep the String.class.php file un-cluttered.
        • geoTable
          NOT FULLY IMPLEMENTED! Do not use this class yet as it is not finished and may change drastically before we are done with it, or may even be removed.
        • geoTableRow
          NOT FULLY IMPLEMENTED! Do not use this class yet as it is not finished and may change drastically before we are done with it, or may even be removed.
        • geoTableRowset
          NOT FULLY IMPLEMENTED! Do not use this class yet as it is not finished and may change drastically before we are done with it, or may even be removed.
        • geoTableSelect
          Class used to generate a select query, useful when multiple areas want to affect a single query, for instance when generating a search query and there are addons involved.
        • geoTables
          Used to hold database table names, used throughout the code.
        • geoTemplate
          Template object that extends the Smarty class (a 3rd party library) to enable using templates to display things.
        • geoTransaction
          This is the object used for a transaction in the order and invoice system.
        • geoUser
          An object representative of a certain user in the system.
        • geoUserRating
          Store, retrieve, and display inter-user ratings
        • geoUtil
          Misc utility functions
        • geoView
          As the name implies, this is used for creating the page view. It does take a little setup (like any class), the setup is normally done in the display_page method in geoSite, or display_page in geoAdmin if displaying a page in the admin.
        • iApiTransport
          Interface for API Transports, a transport must implement this interface for the system to use it.
        • iOrderItem
          You cannot have abstract static functions, so instead need to have an interface to force the given static functions to be defined.
        • metaDbTables
          Used so that old locations that use the old name geoTables will still work.