/**
  * Get all transactions for the current customer
  * @param $result
  * @return mixed
  */
 public function getCustomerTransactions($result)
 {
     // Safety check
     if (!isset($_SESSION['cust_id'])) {
         $result['error'] = "Customer ID not found in current session";
         return $result;
     }
     // Get customer transactions
     $transMdl = new TransactionsModel();
     $trans = $transMdl->getByCustomer($_SESSION['cust_id']);
     if ($trans === false) {
         $result['error'] = "Could not fetch your transactions: " . $transMdl->errorInfo;
     } else {
         $result['data'] = [];
         // decode JSON and add extras
         foreach ($trans as $tran) {
             $record = json_decode($tran['data']);
             $record->type = $tran['type'];
             $result['data'][$tran['ref']] = $record;
         }
     }
     return $result;
 }