private function customer($method, $params, $from, $con) { $results = []; // list of all method that can be called in current module $registeredMethod = array('create', 'destroy', 'listSales', 'loadFormEdit', 'read', 'update', 'viewDetail'); // if called method is not registered then deny access if (!in_array($method, $registeredMethod)) { throw new Exception('Wrong turn buddy'); } // get Current User $currentUser = $from->Session->get('pos/current_user'); // route to requested module and method $results = Customers::$method($params, $currentUser, $con); // followup action if ($method == 'viewDetail') { // send transaction chart's data on picked month $data = Customers::last7MonthsTransactions($params, $currentUser, $con); $transaction['event'] = 'customer/last7MonthsTransactions'; $transaction['data'] = $data; $from->send(json_encode($transaction)); } return $results; }