<?php
class RecepcionarAction extends wtActions
{
    public function execute()
    {
        $this->block      = $this->getRequestParameter( 'block' );
        $this->i_Id       = $this->getRequestParameter( 'i_Id' );
        $this->secuencia  = $this->getRequestParameter( 'secuencia' );
        $this->s_TipoProc = $this->getRequestParameter( 's_TipoProc' );
        
        $a_Ids = explode( "_", $this->i_Id );
        $IdCompania    = $a_Ids[0];
        $IdOrdenCompra = $a_Ids[1];
        
        $o_COM_OrdenCompraCabeceraFN = new COM_OrdenCompraCabeceraFN();
        $this->o_COM_OrdenCompraCabeceraBN = $o_COM_OrdenCompraCabeceraFN->selectByPK( $IdCompania, $IdOrdenCompra );
        
        $a_Secuandia = explode( "_", $this->secuencia );
        
        $o_COM_OrdenCompraDetalleFN = new COM_OrdenCompraDetalleFN();
        $o_COM_OrdenCompraDetalleFN->setIdCompania( ( int ) $IdCompania );
        $o_COM_OrdenCompraDetalleFN->setIdOrdenCompra( ( int ) $IdOrdenCompra );
        $o_COM_OrdenCompraDetalleFN->addCondition( COM_OrdenCompraDetalleFN::IdSecuencia, "IN", "( '".implode( "','", $a_Secuandia )."' ) ", false );
        $this->a_COM_OrdenCompraDetalle = $o_COM_OrdenCompraDetalleFN->select();
        
        $o_GSS_CompaniaFN = new GSS_CompaniaFN();
        $o_GSS_CompaniaFN->setEstado( "A" );
        $o_GSS_CompaniaFN->addOrderBy( GSS_CompaniaFN::DescripcionCorta );
        $this->a_GSS_Compania= $o_GSS_CompaniaFN->select();
        
        $o_ALM_TransaccionMastFN = new ALM_TransaccionMastFN();
        $o_ALM_TransaccionMastFN->setIngresoEgresoFlag( COM_OrdenCompraCabeceraBN::TIPO_TRANSACCION_X_DEFECTO );
        $this->a_ALM_TransaccionMast = $o_ALM_TransaccionMastFN->select();
        
        $o_ALM_AlmacenMastFN = new ALM_AlmacenMastFN();
		$o_ALM_AlmacenMastFN->addCondition( ALM_AlmacenMastFN::Estado ,"<>", "I" );
		$o_ALM_AlmacenMastFN->addCondition( ALM_AlmacenMastFN::IdAlmacen , "IN", "( SELECT IdAlmacen FROM ALM_ItemAlmacenStock S LEFT JOIN ALM_ItemMast I ON I.IdItem=S.IdItem WHERE I.IdItemTipo=\"02\" AND S.StockActual>0 )", false );
		$o_ALM_AlmacenMastFN->addOrderBy( ALM_AlmacenMastFN::DescripcionLocal );
        $o_ALM_AlmacenMastFN->setIdCompania( myUser::getUser()->getIdBusiness() );
        $this->a_ALM_AlmacenMastOrg = $o_ALM_AlmacenMastFN->select();
        
        $o_ALM_TipoDocumentoFN = new ALM_TipoDocumentoFN(); //PARA DOCUMENTO DE REFENCIA
        $o_ALM_TipoDocumentoFN->setEstado( "A" );
        $o_ALM_TipoDocumentoFN->setTransaccionSistemaFlag( "S" );
        $this->a_ALM_TipoDocumento = $o_ALM_TipoDocumentoFN->select();
    }
}