ACC SHELL

Path : /srv/www/vhosts/ambfinance/admin/application/default/controllers/
File Upload :
Current File : /srv/www/vhosts/ambfinance/admin/application/default/controllers/TypController.php

<?php
class TypController extends TF_Controller_Action
{
    /**
     * The default action - show the home page
     */
    public function indexAction ()
    {
        $model = new BusinessType();
        $this->view->data = $model->getAll(array());
    }
    
public function upravitAction()
    {
    	$id = $this->_getParam('id',-1);
    	$model = new BusinessType();
    	$item = $model->find($id)->current();
    	$form = $this->view->form = new Form_BusinessType();
    	if ($this->_request->isPost()) {
    		if ($form->isValid($_POST)) {
    			$vals = (object)$form->getValues();
    			$item->name 				= $vals->name;
    			$item->save();
    			$this->_addFlashMessage('Upraveno');
    			$this->_helper->redirector('index');
    		} 
    	} else {
    		$form->populate($item->toArray());
    	}
    }
    
	public function detailAction()
    {
    	$id = $this->_getParam('id',-1);
    	$model = new BusinessType();
    	$this->view->item = $model->find($id)->current();
    }
    
	public function pridatAction()
    {
    	$model = new BusinessType();
    	$item = $model->createRow();
    	$form = $this->view->form = new Form_BusinessType();
    	if ($this->_request->isPost()) {
    		if ($form->isValid($_POST)) {
    			$vals = (object)$form->getValues();
    			$item->name 				= $vals->name;
    			$item->save();
    			$this->_addFlashMessage('Přidáno');
    			$this->_helper->redirector('index');
    		} 
    	} 
    }
    
    public function smazatAction()
    {
    	$id = $this->_getParam('id',-1);
    	$model = new BusinessType();
    	$item = $model->find($id)->current();
    	try{
    		$item->delete();
    		$this->_addFlashMessage('Smazáno');
    	} catch (Zend_Db_Exception $e) {
    		if (strpos($e->getMessage(), 'SQLSTATE[HY000]: General error: 1451') !== false) {
    			$this->_addFlashMessage('Tento záznam nelze smazat. Pravděpodobně existují záznamy v jiných tabulkách, které ho používají.', 'error');
    		} else {
    			throw $e;
    		}	
    	}
    	$this->_helper->redirector('index');
    }
}

ACC SHELL 2018