aboutsummaryrefslogtreecommitdiff
path: root/muamba.business.inc
diff options
context:
space:
mode:
Diffstat (limited to 'muamba.business.inc')
-rw-r--r--muamba.business.inc60
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() {