rendered paste body<?php
// auto-generated by sfPropelAdmin
// date: 2007/07/23 15:19:00
?>
<?php
/**
* autoPedidos actions.
*
* @package ##PROJECT_NAME##
* @subpackage autoPedidos
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
* @version SVN: $Id: actions.class.php 3501 2007-02-18 10:28:17Z fabien $
*/
class autoPedidosActions extends sfActions
{
public function executeIndex()
{
return $this->forward('pedidos', 'list');
}
public function executeList()
{
$this->processSort();
$this->processFilters();
// pager
$this->pager = new sfPropelPager('Pedidos', 20);
$c = new Criteria();
$this->addSortCriteria($c);
$this->addFiltersCriteria($c);
$this->pager->setCriteria($c);
$this->pager->setPage($this->getRequestParameter('page', 1));
$this->pager->init();
}
public function executeCreate()
{
return $this->forward('pedidos', 'edit');
}
public function executeSave()
{
return $this->forward('pedidos', 'edit');
}
public function executeEdit()
{
$this->pedidos = $this->getPedidosOrCreate();
if ($this->getRequest()->getMethod() == sfRequest::POST)
{
$this->updatePedidosFromRequest();
$this->savePedidos($this->pedidos);
$this->setFlash('notice', 'Your modifications have been saved');
if ($this->getRequestParameter('save_and_add'))
{
return $this->redirect('pedidos/create');
}
else if ($this->getRequestParameter('save_and_list'))
{
return $this->redirect('pedidos/list');
}
else
{
return $this->redirect('pedidos/edit?id='.$this->pedidos->getId());
}
}
else
{
$this->labels = $this->getLabels();
}
}
public function executeDelete()
{
$this->pedidos = PedidosPeer::retrieveByPk($this->getRequestParameter('id'));
$this->forward404Unless($this->pedidos);
try
{
$this->deletePedidos($this->pedidos);
}
catch (PropelException $e)
{
$this->getRequest()->setError('delete', 'Could not delete the selected Pedidos. Make sure it does not have any associated items.');
return $this->forward('pedidos', 'list');
}
return $this->redirect('pedidos/list');
}
public function handleErrorEdit()
{
$this->preExecute();
$this->pedidos = $this->getPedidosOrCreate();
$this->updatePedidosFromRequest();
$this->labels = $this->getLabels();
return sfView::SUCCESS;
}
protected function savePedidos($pedidos)
{
$pedidos->save();
}
protected function deletePedidos($pedidos)
{
$pedidos->delete();
}
protected function updatePedidosFromRequest()
{
$pedidos = $this->getRequestParameter('pedidos');
if (isset($pedidos['produto_id']))
{
$this->pedidos->setProdutoId($pedidos['produto_id'] ? $pedidos['produto_id'] : null);
}
if (isset($pedidos['vendas_id']))
{
$this->pedidos->setVendasId($pedidos['vendas_id'] ? $pedidos['vendas_id'] : null);
}
if (isset($pedidos['quantidade']))
{
$this->pedidos->setQuantidade($pedidos['quantidade']);
}
if (isset($pedidos['preco_venda']))
{
$this->pedidos->setPrecoVenda($pedidos['preco_venda']);
}
}
protected function getPedidosOrCreate($id = 'id')
{
if (!$this->getRequestParameter($id))
{
$pedidos = new Pedidos();
}
else
{
$pedidos = PedidosPeer::retrieveByPk($this->getRequestParameter($id));
$this->forward404Unless($pedidos);
}
return $pedidos;
}
protected function processFilters()
{
}
protected function processSort()
{
if ($this->getRequestParameter('sort'))
{
$this->getUser()->setAttribute('sort', $this->getRequestParameter('sort'), 'sf_admin/pedidos/sort');
$this->getUser()->setAttribute('type', $this->getRequestParameter('type', 'asc'), 'sf_admin/pedidos/sort');
}
if (!$this->getUser()->getAttribute('sort', null, 'sf_admin/pedidos/sort'))
{
}
}
protected function addFiltersCriteria($c)
{
}
protected function addSortCriteria($c)
{
if ($sort_column = $this->getUser()->getAttribute('sort', null, 'sf_admin/pedidos/sort'))
{
$sort_column = PedidosPeer::translateFieldName($sort_column, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME);
if ($this->getUser()->getAttribute('type', null, 'sf_admin/pedidos/sort') == 'asc')
{
$c->addAscendingOrderByColumn($sort_column);
}
else
{
$c->addDescendingOrderByColumn($sort_column);
}
}
}
protected function getLabels()
{
return array(
'pedidos{produto_id}' => 'Produto:',
'pedidos{vendas_id}' => 'Venda nº.:',
'pedidos{quantidade}' => 'Quantidade:',
'pedidos{preco_venda}' => 'Preco venda:',
);
}
}