<?php
/* Busqueda de registros de la tabla ALM_ReservaItemStock redefinidos por el usuario. */
class ALM_ReservaItemStockFN extends BaseALM_ReservaItemStockFN
{
    public function select_custom()
    {
        $s_Where = "";

        if( $this->getIdCompania() )
        {
            $s_Where .= " and IdCompania='{$this->getIdCompania()}' ";
        }
        if( $this->getIdAlmacen() )
        {
            $s_Where .= " and IdAlmacen='{$this->getIdAlmacen()}' ";
        }

        $s_Sql = "SELECT * FROM ALM_ReservaItemStock WHERE 1=1  and IdItem='{$this->getIdItem()}' $s_Where ";
        $a_ALM_ReservaItemStock = array();
        $o_ResultSet = Conexion::getConexion()->prepareStatement( $s_Sql )->executeQuery();
        while( $o_ResultSet->next() ) 
        {
            $a_SQLRow = $o_ResultSet->getRow();
            $o_ALM_ReservaItemStockBN = $this->insertObjectBN( $a_SQLRow );
            $a_ALM_ReservaItemStock[] = $o_ALM_ReservaItemStockBN;
        }
        return $a_ALM_ReservaItemStock;
    }

    public static function getObjectReservaItemxDocDetalle( $o_VTA_DocumentoDetalleBN )
    {
        $o_ALM_ReservaItemStockFN = new ALM_ReservaItemStockFN();
        //$o_ALM_ReservaItemStockFN->setReservaDocTipo( $o_VTA_DocumentoDetalleBN->getIdTipoDocumento() );
        //$o_ALM_ReservaItemStockFN->setReservaDocNumero( $o_VTA_DocumentoDetalleBN->getReservaDocNumero() );
        $o_ALM_ReservaItemStockFN->setIdItem( $o_VTA_DocumentoDetalleBN->getItemCodigo() );
        $o_ALM_ReservaItemStockFN->setIdAlmacen( $o_VTA_DocumentoDetalleBN->getAlmacenCodigo() );
        $o_ALM_ReservaItemStockFN->setIdCompania( $o_VTA_DocumentoDetalleBN->getIdCompania() );
        $o_ALM_ReservaItemStockFN->setIdLote( $o_VTA_DocumentoDetalleBN->getLote() );
        $o_ALM_ReservaItemStockFN->setReservaRefNumero( $o_VTA_DocumentoDetalleBN->getNumeroDocumento() );
        $o_ALM_ReservaItemStockFN->setReservaSecuencia( $o_VTA_DocumentoDetalleBN->getSecuencia() );
        $a_ALM_ReservaItemStock = $o_ALM_ReservaItemStockFN->select();

        if( $a_ALM_ReservaItemStock )
        {
            return $a_ALM_ReservaItemStock[0];
        }
        return null;
    }

    public static function getObjectReservaItemxDocOrdDetalle( $o_VTA_OrdenDetalleBN )
    {
        $o_ALM_ReservaItemStockFN = new ALM_ReservaItemStockFN();
        //$o_ALM_ReservaItemStockFN->setReservaDocTipo( $o_VTA_DocumentoDetalleBN->getIdTipoDocumento() );
        //$o_ALM_ReservaItemStockFN->setReservaDocNumero( $o_VTA_DocumentoDetalleBN->getReservaDocNumero() );
        $o_ALM_ReservaItemStockFN->setIdItem( $o_VTA_OrdenDetalleBN->getItemCod() );
        $o_ALM_ReservaItemStockFN->setIdAlmacen( $o_VTA_OrdenDetalleBN->getAlmacenCod() );
        //$o_ALM_ReservaItemStockFN->setIdCompania( $o_VTA_DocumentoDetalleBN->getIdCompania() );
        $o_ALM_ReservaItemStockFN->setIdLote( $o_VTA_OrdenDetalleBN->getLoteNum() );
        $o_ALM_ReservaItemStockFN->setReservaRefNumero( $o_VTA_OrdenDetalleBN->getOrdenId() );
        $o_ALM_ReservaItemStockFN->setReservaSecuencia( $o_VTA_OrdenDetalleBN->getOrdenDetalleNum() );
        $a_ALM_ReservaItemStock = $o_ALM_ReservaItemStockFN->select();

        if( $a_ALM_ReservaItemStock )
        {
            return $a_ALM_ReservaItemStock[0];
        }
        return null;
    }
}
?>