<?php

/**
 * credenciales actions.
 *
 * @package    comisiones
 * @subpackage credenciales
 * @author     Software House LTDA <gerencia@sofhouse.net>
 * @version    SVN: $Id: actions.class.php 9301 2008-05-27 01:08:46Z dwhittle $
 */
class credencialesActions extends sfActions
{
  protected $Mensajes = array(
                               '&&&' => 'Se ha actualizado el submen&uacute; correctamente'
                               );
                               /**
                                * Executes index action
                                *
                                * @param sfRequest $request A request object
                                */
                               public function executeIndex($request)
                               {
                                 $c = new Criteria();
                                 $c->addAscendingOrderByColumn(MenusPeer::DESCRIPCION);
                                 $this->menus = MenusPeer::doSelect($c);
                               }

                               public function handleErrorListar()
                               {
                                 $this->forward('credenciales', 'index');
                               }

                               public function executeListar($request){
                                 $request->getParameterHolder()->get('_') ? $this->mensaje = $this->Mensajes[$request->getParameterHolder()->get('_')] : '';
                                 $c = new Criteria();
                                 $c->add(CredencialesPeer::ID_MENU,$this->getRequestParameter('id_menu'));
                                 $c->addAscendingOrderByColumn(CredencialesPeer::ORDEN);
                                 $this->credenciales = CredencialesPeer::doSelectJoinMenus($c);
                               }

                               public function executeEdit($request)
                               {
                                 $this->id = $this->getRequestParameter('id');
                                 $this->forward404If(!$request->isMethod('POST'));
                                 $this->credencial = CredencialesPeer::retrieveByPk($this->id);
                                 $this->titulo = "Edici&oacute;n del submen&uacute; " . strtoupper($this->credencial->getDescripcion());
                                 $c = new Criteria();
                                 $c->addAscendingOrderByColumn(MenusPeer::DESCRIPCION);
                                 $this->menus = MenusPeer::doSelect($c);
                               }

                               public function handleErrorUpdate()
                               {
                                 $this->forward('credenciales', 'edit');
                               }

                               public function executeUpdate($request)
                               {
                                 $this->forward404If(!$request->isMethod('POST'));
                                 //Se actualiza el usuario
                                 $mensaje = '&&&';
                                 $credencial = CredencialesPeer::retrieveByPk($this->getRequestParameter('id'));
                                 $credencial->setDescripcion($this->getRequestParameter('descripcion'));
                                 $credencial->setIdMenu($this->getRequestParameter('id_menu'));
                                 $credencial->setorden($this->getRequestParameter('orden'));
                                 $credencial->save();
                                 return $this->redirect("credenciales/listar?_=$mensaje&id_menu=" . $this->getRequestParameter('id_m'));
                               }
}
