<?php

/**
 * generar_aportes_correc actions.
 *
 * @package    nomina
 * @subpackage generar_aportes_correc
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class generar_aportes_correcActions 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->id_periodo_retro = $request['id_periodo_retroA'] . ',' . $request['id_periodo_retroB'];
        $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->num_planilla = $request['num_planilla'];
        $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->id_periodo_retro = $request['id_periodo_retroA'] . ',' . $request['id_periodo_retroB'];
        $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->num_planilla = $request['num_planilla'];
        $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
         * Tener en cuenta variables false - 20201027
         */
        $this->aplica_ibc_ant_vac = 0;
        //Sql
        $sql = <<<EOD
select aplica_ibc_ant_vac as tag_vac_ibc 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]['tag_vac_ibc'];
        }

        /*
         * (SGC-1, ANM-2, SGR-3, CYC-4, COL-5, INCI-6, LOCAL-7)
         */
        $array = sfYaml::load(dirname(__FILE__) . '/../../../../api/config/app-gwt.yml');

        $int = 0;
        $this->correoEnvio = "";
        $this->service_url = "";

        foreach ($array as $routeName => $routeData) {
            if ('service_url_local' == $routeName) {
                foreach ($routeData as $key => $value) {
                    if ($key == 'value') {
                        $this->service_url = $value;
                    }
                }
            }
            if ('correoEnvio' == $routeName) {
                foreach ($routeData as $key => $value) {
                    //echo $value . "\n";
                    if ($key == 'value') {
                        $this->correoEnvio = $value;
                    }
                }
            }
            $int++;
        }
    }

}
