From 461a0d5737e8aec766758c9887904d53eb177e8f Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Mon, 26 Sep 2011 21:11:41 -0300 Subject: Adding more transaction logic --- muamba.business.inc | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'muamba.business.inc') diff --git a/muamba.business.inc b/muamba.business.inc index 5efb469..1b40d1b 100644 --- a/muamba.business.inc +++ b/muamba.business.inc @@ -9,6 +9,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. */ -- cgit v1.2.3