/var/www/vhosts/ihelp.ro/httpdocs/src/Controller/Admin
Edit: /var/www/vhosts/ihelp.ro/httpdocs/src/Controller/Admin/BankAccountsController.php (3144B)
paginate = [
'contain' => ['Causes'],
];
$bankAccounts = $this->paginate($this->BankAccounts);
$bankAccountType = Configure::read('account_type');
$this->set(compact('bankAccounts','bankAccountType'));
}
/**
* Add method
*/
public function add()
{
$bankAccount = $this->BankAccounts->newEmptyEntity();
if ($this->request->is('post')) {
$bankAccount = $this->BankAccounts->patchEntity($bankAccount, $this->request->getData());
if ($this->BankAccounts->save($bankAccount)) {
$this->Flash->success(__('The bank account has been saved.'));
return $this->redirect(['prefix' => 'Admin', 'controller' => 'BankAccounts', 'action' => 'add']);
}
$this->Flash->error(__('The bank account could not be saved. Please, try again.'));
}
$causes = $this->BankAccounts->Causes->find('list', ['limit' => 200]);
$bankAccountType = Configure::read('account_type');
$this->set(compact('bankAccount', 'causes', 'bankAccountType'));
}
/**
* Edit method
*/
public function edit($id = null)
{
$bankAccount = $this->BankAccounts->get($id, [
'contain' => [],
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$bankAccount = $this->BankAccounts->patchEntity($bankAccount, $this->request->getData());
if ($this->BankAccounts->save($bankAccount)) {
$this->Flash->success(__('The bank account has been saved.'));
return $this->redirect(['prefix' => 'Admin', 'controller' => 'BankAccounts', 'action' => 'edit', 'id' => $id]);
}
$this->Flash->error(__('The bank account could not be saved. Please, try again.'));
}
$causes = $this->BankAccounts->Causes->find('list', ['limit' => 200]);
$bankAccountType = Configure::read('account_type');
$this->set(compact('bankAccount', 'causes', 'bankAccountType'));
}
/**
* Delete method
*/
public function changeStatus($id = null)
{
$this->request->allowMethod(['post', 'delete']);
$bankAccount = $this->BankAccounts->get($id);
$bankAccount->is_active = $bankAccount->is_active ? false : true;
if ($this->BankAccounts->save($bankAccount)) {
if ($bankAccount->is_active == true) {
$this->Flash->success(__('The bank account has been enabled.'));
} else {
$this->Flash->success(__('The bank account has been disabled.'));
}
} else {
$this->Flash->error(__('The bank account could not be disabled. Please, try again.'));
}
return $this->redirect(['prefix' => 'Admin', 'controller' => 'BankAccounts', 'action' => 'index']);
}
}