<?php

/**
 * actualizar_persona actions. - 20190715
 *
 * @package    canon
 * @subpackage actualizar_persona
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class actualizar_personaActions extends sfActions {

    /**
     * Executes list action
     *
     * @param sfRequest $request A request object
     */
    public function executeList(sfWebRequest $request) {

        //Revisar que sea post
        //$this->forward404Unless($request->isMethod('post'));
        //Guardar los parametros del request en el log
        $this->logMessage("---BEGIN Logging request");
        foreach ($request->getPostParameters() as $key => $value) {
            $this->logMessage("request[$key] = $value");
        }
        $this->logMessage("--------------------------------------------------/  Ip: " . $_SERVER['REMOTE_ADDR']);
        foreach ($request->getGetParameters() as $key => $value) {
            $this->logMessage("request[$key] = $value");
        }
        $this->logMessage("---END Logging request");


        /*
         * Manejo de errores
         */
        try {

            $this->conn = Doctrine_Manager::getInstance()->getCurrentConnection();
            $this->conn->beginTransaction();

            /*
             * Variable Obligatorias
             */

            $id_persona = $request['id_persona'];
            $correo_notif = $request['correo_notif'];

            $sql = <<<EOD
update rmn_persona set correo_notif = '$correo_notif'
where id_persona = $id_persona 
EOD;

            $this->conn->execute($sql);

            //COMMIT DE TODAS LAS TRANSACCIONES
            $this->conn->commit();
            $this->list_data = array();
            $this->status = 0;
            $this->logMessage("Se actualizo correo de persona.");
        } catch (Exception $e) {
            //ROLLBACK DE TODAS LAS TRANSACCIONES EN CASO DE QUE OCURRA ALGUN ERROR
            $this->conn->rollback();
            $this->status = 1;
            $this->mensajeError = "ERROR!!!";
            $this->list_data = array();
            $this->logMessage("ERROR!!!");
            $this->logMessage($e->getMessage());
        }
    }

}
