<?php 
ini_set('display_errors','On');
require_once($_SERVER['DOCUMENT_ROOT'].'/shine/datos/clsQuery.php');
	class clsCliente extends Query 
	{
		var $filas = NULL;
		function __construct()  
		{
			parent::__construct();
			parent::MET_Conectar();
		}      
		
		function MET_consultaAlmacenes($CodigoSocio)  {		
			$sql = "SELECT ALMACEN, NOMBALMACEN, DOCENTRY, SUM(NROCABEZAS) AS NROCABEZAS
					FROM
						sei_rpt_seguimientos2
						WHERE CODIGOSOCIO = \'$CodigoSocio\'
						GROUP BY ALMACEN, NOMBALMACEN, DOCENTRY
						ORDER BY ALMACEN, NOMBALMACEN, DOCENTRY
					;";
			//$sql = "select num_emision from facturacion.m_emisionxempresa where num_anio=to_char(now(),\'YYYY\')::smallint and id_status=1 and id_empresa=$tipo;";
		//	echo $sql;exit;
            parent::__set('sql', $sql);
            $registros = parent::MET_Select();
            return $registros;
        }
		
		function MET_fillCombo($opt,$first,$CodigoSocio)  {
            $registros = $this->MET_consultaAlmacenes($CodigoSocio);
            $combo = '<option value="0" >'.$first.'</option>';
            foreach($registros as $ind => $reg) {
				$selected='selected';
				//($opt == $reg['num_emision']) ? $selected='selected' : $selected='';  
                $combo .= '<option value="'.$reg['DOCENTRY'].'" '.$selected.' >'.$reg['ALMACEN'].' - '.$reg['NOMBALMACEN'].' ('.$reg['NROCABEZAS'].')'.'</option>';
            }
			//print_r($combo);
            return $combo;			
        }
		
		function MET_consultaInversor($CodigoSocio)  {		
			$sql = "SELECT CODIGOSOCIO, NOMBRESOCIO, SUM(NROCABEZAS) AS NROCABEZAS
					FROM
						sei_rpt_seguimientos2
						WHERE ALMACEN = \'$CodigoSocio\'
						GROUP BY CODIGOSOCIO, NOMBRESOCIO
						ORDER BY CODIGOSOCIO, NOMBRESOCIO
					;";
			//$sql = "select num_emision from facturacion.m_emisionxempresa where num_anio=to_char(now(),\'YYYY\')::smallint and id_status=1 and id_empresa=$tipo;";
		//	echo $sql;exit;
            parent::__set('sql', $sql);
            $registros = parent::MET_Select();
            return $registros;
        }
		
		function MET_fillComboInversor($opt,$first,$CodigoSocio)  {
            $registros = $this->MET_consultaInversor($CodigoSocio);
            $combo = '<option value="0" >'.$first.'</option>';
            foreach($registros as $ind => $reg) {
				$selected='selected';
				//($opt == $reg['num_emision']) ? $selected='selected' : $selected='';  
                $combo .= '<option value="'.$reg['CODIGOSOCIO'].'" '.$selected.' >'.$reg['CODIGOSOCIO'].' - '.$reg['NOMBRESOCIO'].' ('.$reg['NROCABEZAS'].')'.'</option>';
            }
			//print_r($combo);
            return $combo;			
        }

	}//end class
?>
