<?php

/**
 * co_verificar_cdp actions.
 *
 * @package    contratacion
 * @subpackage co_verificar_cdp
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class co_verificar_cdpActions extends sfActions
{
 /**
  * Executes index 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");

        /*
         * Manejar Errores
         */
        try {

            /*
             * Variables para el registro de log
             */

            //1 - indica operacion de consulta
            $id_ope_bd = 1;

            //obtener id maestro tabla
            $id_mae_bd = CN_TABLE::consultarIdTablaBD('co_estudios_previos');

            $id_cdp = $request['id_cdp'];

            //CN_TABLE::registrarLog($request, $id_ope_bd, $id_mae_bd, $observacion);
            
            
            $sql = <<<EOD
select count(*) cantidad

from co_cdps_ep tab0

where tab0.id_cdp = $id_cdp
                    
                    
EOD;
            $records = CN_TABLE::executeSQL($sql);

            //Ejecuta sql
            $this->totalRows = count($records);
            $this->list_data = $records;
        } catch (Exception $e) {

            $this->status = 1;
            $this->totalRows = 0;
            $this->startRow = 0;
            $this->endRow = 0;
            $this->list_data = array();
            $this->logMessage("ERROR!!!");
            $this->logMessage($e->getMessage());
        }
  }
}
