<?php

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

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

        $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");

        /*
         * Variables de filtro
         */
        $this->id_periodo = $request['id_periodo_filtro'];
        $this->id_periodo_actual = $request['id_periodo'];
        $this->vig_ini = $request['vig_ini'];
        $this->per_ini = $request['per_ini'];
        $this->vig_fin = $request['vig_fin'];
        $this->per_fin = $request['per_fin'];
        $this->fecha_pago = $request['fecha_pago'];
    }

    /**
     * Version nueva de planilla de autoliquidacion resolucion 2388 de 2016 - 20170222
     *
     * @param sfRequest $request A request object
     */
    public function executeIndex2388(sfWebRequest $request) {

        $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");

        /*
         * Variables de filtro
         */
        $this->id_periodo = $request['id_periodo_filtro'];
        $this->id_periodo_actual = $request['id_periodo'];
        $this->vig_ini = $request['vig_ini'];
        $this->per_ini = $request['per_ini'];
        $this->vig_fin = $request['vig_fin'];
        $this->per_fin = $request['per_fin'];
        $this->fecha_pago = $request['fecha_pago'];

        /*
         * variables para tipo de archivo de salida - 20180718
         */
        $this->type = $request['type'];

        $consul = Doctrine_Manager::getInstance()->connection();
        $sql = "select * from no_periodo_v where id_periodo=" . $this->id_periodo;
        $st = $consul->execute($sql);
        $periodo = $st->fetchAll();

        $this->nombre_periodo = $periodo[0]['PERIODO'];

        /**
         * Consultar no_param_gen - 20200128
         */
        $this->aplica_ibc_ant_vac = 0;
        //Sql
        $sql = <<<EOD
select * from no_param_gen 
EOD;
        //Ejecutar SQL
        $record_gen = CN_TABLE::executeSQL($sql);
        if (count($record_gen) > 0) {
            $this->aplica_ibc_ant_vac = $record_gen[0]['aplica_ibc_ant_vac'];
        }
    }

}
