<?php

class alertasNominaTask extends sfBaseTask {

    protected function configure() {
        
        // add your own arguments here
        // $this->addArguments(array(
        //   new sfCommandArgument('my_arg', sfCommandArgument::REQUIRED, 'My argument'),
        // ));

        //Log especifico de procesos completos, solo por aqui no en el CRON
        $this->addOptions(array(
            new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'api'),
            new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
            new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine'),
                // add your own options here
        ));

        $this->namespace = 'nomina';
        $this->name = 'alertasNomina';
        $this->briefDescription = '';
        $this->detailedDescription = <<<EOF
The [nomina:alertasNomina|INFO] task does things.
Call it with:

  [php symfony nomina:alertasNomina|INFO]
EOF;
    }

    protected function execute($arguments = array(), $options = array()) {

        $parametros_post = array();

        $sesion = curl_init("http://localhost/nomina/web/api_dev.php/api/envio_alertas/list.json?");
        //Define el tipo de ejecución, en este caso POST
        curl_setopt($sesion, CURLOPT_POST, true);
        //Se ingresan los parametos estabelcidos 
        curl_setopt($sesion, CURLOPT_POSTFIELDS, http_build_query($parametros_post));
        //Parametros de retorno en cURL
        curl_setopt($sesion, CURLOPT_HEADER, false);
        curl_setopt($sesion, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($sesion, CURLOPT_TIMEOUT_MS, 0.1);
        curl_setopt($sesion, CURLOPT_NOSIGNAL, 0.1);
        //Ejecuta la petición
        $respuesta = curl_exec($sesion);
        //Se cierra la conexión
        curl_close($sesion);
    }

}
