<?php use_helper( 'UrlFunctions' ); ?>
<?php use_helper( 'IncludePartial' ); ?>
<?php use_helper( 'UtilFunctions' ); ?>

<script>
ejecutarGuardar = function()
{
    mostrarCargaImg();
    var strFormSerialize = $( 'form' ).serialize();
    executeAjaxJson
    ( 
        "<?php echo buildUrl( 'os/saveAddEdit', "" ) ?>", 
        strFormSerialize,
        function( o_json )
        {
            //console.log( o_json );
            //ocultarCargaImg();
            if( o_json.error )
            {
            	showAlertBootStrap( 'content_alert', 'alert-danger', o_json.mensaje_error );
                return false;
            }
            //return false;
            location.href = "<?=buildUrl( 'os/detail', "s_TipoProc=upd&i_Id=" ) ?>" + o_json.id;
        } 
	);
}
</script>

<style type="text/css">
.ui-dialog .ui-dialog-titlebar-close 
{
    position: absolute;
    right: .3em;
    top: 50%;
    width: 20px;
    margin: -10px 0 0 0;
    padding: 1px;
    height: 20px;
    background-position: -96px -128px;
    /*background-image: url("images/ui-icons_056b93_256x240.png");*/
    background-image: url("<?=Constantes::ROOT_DIR_APP?>web/css/jquery/themes/start_1.12.1/images/ui-icons_056b93_256x240.png");
}
</style>

<script type="text/javascript">

</script>

<div id="content_alert" style=""></div>

<div class="shadow-sm p-3 mb-2 bg-white rounded card card-body">
    <div class="row">
        <div class="col mb-1">
            <h4 class="text-info text-nowrap mb-0"><?=$s_Titulo?></h4>
        </div>
    </div>
</div>


<!-- <ul class="nav nav-pills nav-fill m-2"> -->
<ul class="nav nav-tabs m-1" id="myTab" role="tablist">
	<li class="nav-item">
		<!-- <a class="nav-link active" href="#">General</a> -->
		<a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">General</a>
	</li>
	<?php if( $o_COM_OrdenCompraCabeceraBN->getIdOrdenCompra() ){ ?>
	<li class="nav-item">
		<!-- <a class="nav-link" style="background-color: #DCDCDC;" href="#">Detalles</a>-->
		<a class="nav-link" id="profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false">Detalles</a>
	</li>
	<?php } ?>
</ul>

<?php 
include_partial
( 
    "addedit", 
    array
    ( 
        "o_COM_OrdenCompraCabeceraBN"  => $o_COM_OrdenCompraCabeceraBN, 
        "a_COM_OrdenItemClasificacion" => $a_COM_OrdenItemClasificacion, 
        "o_ALM_AlmacenMastBN"          => $o_ALM_AlmacenMastBN, 
        "a_GSS_MonedaMast"             => $a_GSS_MonedaMast,
        "a_ALM_AlmacenMast"            => $a_ALM_AlmacenMast,
        "s_TipoProc"                   => $s_TipoProc
    )
); 
?>



<script type="text/javascript">
$( '#myTab a' ).on
(
    'click', function ( e ) 
    {
        pr( e );
        //pr( $( e.target ).html() );
        if( $( e.target ).html() == "General" )
        {
        	location.href='<?=buildUrl( 'os/addedit', 's_TipoProc='.$s_TipoProc.'&i_Id='.$i_Id )?>'
        }
        if( $( e.target ).html() == "Detalles" )
        {
        	location.href='<?=buildUrl( 'os/detail', 's_TipoProc='.$s_TipoProc.'&i_Id='.$i_Id )?>'
        }
    }
)
//$('#myTab li:nth-child(3) a').tab('show'); 
</script>

<!-- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<style type="text/css">
.modal
{
 padding: 0 !important;
}
.modal-dialog {
  max-width: 95% !important;
  height: 90%;
/*  padding: 0;
  margin: 0;*/
}

.modal-content {
  /*border-radius: 0 !important;*/
  height: 90%;
}
</style>
<!-- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->

<!-- Modal - NUEVO CLIENTE -->
<div class="modal hide fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLongTitle">Seleccionar Proveedor</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <iframe id="myIframe" src="" style="zoom:0.60;" width="99.6%" height="99.6%" frameborder="0"></iframe>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Cerrar</button>
                <!--<button type="button" class="btn btn-primary">Save changes</button>-->
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
/*asignarValores = function( idpersona )
{
    $( "#ClienteNumero" ).val( idpersona );
    buscarInfoCliente();
    ocultarModal();
}
ocultarModal = function()
{
    $( '#exampleModalCenter' ).modal( 'hide' );
}*/
</script>


<script>
/*
$.validator.setDefaults
(
    {
        submitHandler: function( form ) 
        {
            ejecutarGuardar();
        }
    }
);
$( "#form1" ).validate();
*/

</script>