diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2011-09-26 21:11:41 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2011-09-26 21:11:41 -0300 |
commit | 461a0d5737e8aec766758c9887904d53eb177e8f (patch) | |
tree | eecf527ea1642577a3d1a225c3cfc4fe572bf4d3 /muamba.business.inc | |
parent | 8bc407811575c36fc24dda235e263e9366efbe1e (diff) | |
download | muamba-461a0d5737e8aec766758c9887904d53eb177e8f.tar.gz muamba-461a0d5737e8aec766758c9887904d53eb177e8f.tar.bz2 |
Adding more transaction logic
Diffstat (limited to 'muamba.business.inc')
-rw-r--r-- | muamba.business.inc | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/muamba.business.inc b/muamba.business.inc index 5efb469..1b40d1b 100644 --- a/muamba.business.inc +++ b/muamba.business.inc @@ -10,6 +10,66 @@ include_once('muamba.db.inc'); include_once('muamba.misc.inc'); /** + * Determine possible actions for a transaction. + * + * @param $type + * Transaction type (sent or received). + * + * @param $status + * Current transaction status. + * + * @return + * Array of available action codes. + */ +function muamba_actions_available($type = 'sent', $status) { + if ($type == 'sent') { + switch ($status) { + case MUAMBA_REQUESTED: + $actions = array( + MUAMBA_ACCEPTED, + MUAMBA_REJECTED, + ); + break; + + case MUAMBA_ACCEPTED: + $actions = array( + MUAMBA_RELEASED, + ); + break; + + case MUAMBA_RETURNED: + $actions = array( + MUAMBA_RELEASED, + ); + break; + + default: + $actions = array(); + } + } + else { + switch ($status) { + case MUAMBA_REQUESTED: + $actions = array( + MUAMBA_CANCELLED, + ); + break; + + case MUAMBA_ACCEPTED: + $actions = array( + MUAMBA_RETURNED, + ); + break; + + default: + $actions = array(); + } + } + + return $actions; +} + +/** * Transaction management page. */ function muamba() { |