public function DisplayAction() { //require_once './model/CustomersModel.php'; $customer = new CustomersModel(); $rows = $customer->CustList(); require_once './view/customers.html'; }
/** Update newer tables then sync changes to older tables */ private static function postAccount($dbc, $id, $json) { $ret = array('errors' => 0, 'error-msg' => ''); $config = \FannieConfig::factory(); $account = new \CustomerAccountsModel($dbc); $customers = new \CustomersModel($dbc); $account->cardNo($id); foreach ($account->getColumns() as $col_name => $info) { if ($col_name == 'cardNo') { continue; } if ($col_name == 'customerAccountID') { continue; } if ($col_name == 'modified') { continue; } if (isset($json[$col_name])) { $account->{$col_name}($json[$col_name]); } } if (!$account->save()) { $ret['errors']++; } if (isset($json['customers']) && is_array($json['customers'])) { $columns = $customers->getColumns(); foreach ($json['customers'] as $c_json) { $customers->reset(); $customers->cardNo($id); $deletable = 0; foreach ($columns as $col_name => $info) { if ($col_name == 'cardNo') { continue; } if ($col_name == 'modified') { continue; } if ($col_name == 'customerID' && isset($c_json[$col_name]) && $c_json[$col_name] != 0) { $deletable++; } elseif ($col_name == 'firstName' && isset($c_json[$col_name]) && $c_json[$col_name] == '') { $deletable++; } elseif ($col_name == 'lastName' && isset($c_json[$col_name]) && $c_json[$col_name] == '') { $deletable++; } if (isset($c_json[$col_name])) { $customers->{$col_name}($c_json[$col_name]); } } if ($deletable == 3) { // submitted an ID and blank name fields $customers->delete(); } elseif ($deletable == 2 && $customers->customerID() == 0) { // skip creating member } elseif (!$customers->save()) { $ret['errors']++; } } } // mirror changes to older tables if ($config->get('CUST_SCHEMA') == 1) { $account->legacySync($id); $customers->legacySync($id); } $ret['account'] = self::get($id); return $ret; }