<?php 

session_start();
if($_SESSION["sistema"]!= "1"){ header("location: ../login/index.php"); exit();}


?>

<style type="text/css">
select{
	cursor:pointer;
}

</style>

<div class="content-header" >
      <div class="container-fluid">
        <div class="row mb-2">
		 <div class="col-sm-6">
			<h1>
			Orden compra
			<small>modulo</small>
			</h1>
		</div>	
		
		<div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
				<li class="breadcrumb-item" >Inicio</li>
				<li class="breadcrumb-item" >Menu</li>
				<li class="breadcrumb-item active">Orden compra</li>
            </ol>
          </div>
		</div>
	</div>
</div>



<section class="content">
	<div class="container-fluid">
	<div class="row">
	    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" style="padding:0px;"  >
		    <div class="card">
		        <div class="card-header">
					
				<span id="btn_actualizar" class="btn btn-default">Actualizar</span>
				
		        </div>
		    </div>
		</div>
	</div>
	</div>
</section>




		<!-- formulario de registro -->
			<div class="modal fade" id="div_compra_form_dialog" role="dialog" data-keyboard="false" data-backdrop="static" tabindex="-1"  style="padding:0px;overflow-y:scroll;">
			<div class="modal-dialog modal-xl" style="width: 95% !important;"   role="document" >

			<div class="modal-content">

			<div class="modal-body div_compra_form" style="padding:0%;" >

			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			
			
			
<!-- formulario de mensaje -->
			<div class="modal fade" id="div_mensaje_dialog" role="dialog" data-keyboard="false" data-backdrop="static" tabindex="-1"  
			style="padding:0px; overflow-y:scroll;z-index:9999;">
			<div class="modal-dialog modal-md"  role="document" >

			<div class="modal-content" style="padding:0px;">

			<div class="modal-body div_mensaje"  >

			
		
			
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>		
			
			
	<!-- formulario de registro -->
			<div class="modal fade" id="div_ordencompra_form_dialog" role="dialog" data-keyboard="false" data-backdrop="static" tabindex="-1"  style="padding:0px; overflow-y:scroll;">
			<div class="modal-dialog modal-lg"   style="width: 95% !important;" role="document" >

			<div class="modal-content">

			<div class="modal-body div_ordencompra_form" style="padding:0%;" >

			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			
			
			<!-- formulario de pago venta -->
			<div class="modal fade" id="div_venta_form_dialog" role="dialog" data-keyboard="false" data-backdrop="static" tabindex="-1"  style="padding:0px; overflow-y:scroll;">
			<div class="modal-dialog "  role="document" >

			<div class="modal-content">

			<div class="modal-body div_venta_form" style="padding:0%;" >

			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			
			<div class="modal fade" id="div_ordencompra_correo_form" role="dialog" data-keyboard="false" data-backdrop="static" style="padding:0px; overflow-y:scroll ">
			<div class="modal-dialog modal-lg"  >

			<div class="modal-content">

			<div class="modal-body div_ordencompra_correo_conten" style="padding:0px;"   >

			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			
			
				<!-- formulario de registro para proveedores -->
		<div class="modal fade" id="div_proveedor_form_dialog" role="dialog" data-keyboard="false" data-backdrop="static" tabindex="-1"  style="padding:0px; overflow-y:scroll;">
			<div class="modal-dialog modal-lg"  role="document" >

			<div class="modal-content">

			<div class="modal-body div_proveedor_form"  >

			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			
				<!-- formulario de registro -->
			<div class="modal fade" id="div_productomarca_form_dialog" role="dialog" data-keyboard="false" data-backdrop="static" tabindex="-1"  style="padding:0px;overflow-y:scroll;">
			<div class="modal-dialog modal-xl" style="width: 90% !important;"   role="document" >

			<div class="modal-content">

			<div class="modal-body div_productomarca_form" >

			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			
			
									
		<div class="modal fade" id="div_productocodigointerno_form_dialog" role="dialog" data-keyboard="false" data-backdrop="static" tabindex="-1" 
			style="padding:0px;overflow-y:scroll;">
			<div class="modal-dialog modal-sm" role="document" >
			<div class="modal-content">
			<div class="modal-body div_productocodigointerno_form" style="padding:0px;" >
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
					
					
		
				
<!-- Filter content -->
<div id="div_ordencompra_filtro"></div>
<!-- Table content -->
<div id="div_ordencompra_tabla"></div>



	<script type="text/javascript">
		
			function compra_form_vista(act,idf,pagar){
			$('#div_compra_form_dialog').modal();
		$('body').css('overflow-y','hidden');
			$.ajax({
				type: "POST",
				url: "../compra/compra_form.php",
				async:true,
				dataType: "html",                      
				data: ({
					action: act,
					com_id:	idf,
					com_pagar:pagar,
					vista:'compra_form'
				}),
				beforeSend: function() {
					var div = "<center> <br> <span class='spinner-border spinner-border-lg mr-2'></span> <span style='font-size:1.5rem;'>PROCESANDO PETICIÓN</span></center>";	
					$('.div_compra_form').html(div);
				},
				success: function(html){
					$('.div_compra_form').html(html);				
				}
			});
		}


		function compra_form(act,ordcom_id){
			$('#div_compra_form_dialog').modal();
		$('body').css('overflow-y','hidden');
			$.ajax({
				type: "POST",
				url: "../compra/compra_form.php",
				async:true,
				dataType: "html",                      
				data: ({
					action: act,
					ordcom_id:ordcom_id,
					vista:'ordencompra_form'
				}),
				beforeSend: function() {
					var div = "<center> <br> <span class='spinner-border spinner-border-lg mr-2'></span> <span style='font-size:1.5rem;'>PROCESANDO PETICIÓN</span></center>";	
					$('.div_compra_form').html(div);
				},
				success: function(html){
					$('.div_compra_form').html(html);				
				}
			});
		}

		
		
		function ordencompra_form_vista(act,idf){
			$('#div_ordencompra_form_dialog').modal();
			//$('body').css('padding-right','0px');
			$.ajax({
				type: "POST",
				url: "../ordencompra/ordencompra_form_vista.php",
				async:true,
				dataType: "html",                      
				data: ({
					action: act,
					cotid:	idf
				}),
				beforeSend: function() {
					var div = "<center> <br> <span class='spinner-border spinner-border-lg mr-2'></span> <span style='font-size:1.5rem;'>PROCESANDO PETICIÓN</span></center>";	
					$('.div_ordencompra_form').html(div); 
				},
				success: function(html){
					$('.div_ordencompra_form').html(html);	
				},
				complete: function(){
				}
			});
		}
	
		function ordencompra_form(act,idf,est){
				
				$('#div_ordencompra_form_dialog').modal();

				$.ajax({
					type: "POST",
					url: "../ordencompra/ordencompra_form.php",
					async:true,
					dataType: "html",   
					position:'top',                   
					data: ({
						action: act,
						ordcom_id: idf,
						ordcom_est: est
					}),
					beforeSend: function() {
						var div = "<center> <br> <span class='spinner-border spinner-border-lg mr-2'></span> <span style='font-size:1.5rem;'>PROCESANDO PETICIÓN</span></center>";	
						$('.div_ordencompra_form').html(div);
					},
					success: function(html){
						$('.div_ordencompra_form').html(html);				
					},
					complete: function(){

					}
				});
			}
			
		function ordencompra_filtro(){
			$.ajax({
				type: "POST",
				url: "../ordencompra/ordencompra_filtro.php",
				dataType: "html",
				beforeSend: function() {
					$('#div_ordencompra_filtro').addClass("ui-state-disabled");
				},
				success: function(html){
					$('#div_ordencompra_filtro').html(html);
				},
				complete: function(){			
					$('#div_ordencompra_filtro').removeClass("ui-state-disabled");
				}
			}); 
		}
		
		function ordencompra_tabla(){
		$('#div_mensaje_dialog').show(100);
			$.ajax({
				type: "POST",
				url: "../ordencompra/ordencompra_tabla.php",
				dataType: "html",
				data:  $("#for_fil_ordcom").serialize(),
				beforeSend: function() {
					var div = "<center> <br> <span class='spinner-border spinner-border-lg mr-2'></span> <span style='font-size:1.5rem;'>PROCESANDO PETICIÓN</span></center>";	
					$('.div_mensaje').html(div);
					$('#div_ordencompra_tabla').addClass("ui-state-disabled");
				},
				success: function(html){
					$('#div_ordencompra_tabla').html(html);
				},
				complete: function(){	
				
					$('#div_mensaje_dialog').hide('fade');				
					
					$('#div_ordencompra_tabla').removeClass("ui-state-disabled");
					
				}
			}); 
		}
		
			
		function ordencompra_anular(act,id,texto){   
		if(confirm("Realmente desea anular la ordencompra Nº "+texto+", Continuar?")){
			$.ajax({
				type: "POST",
				url: "../ordencompra/ordencompra_reg.php",
				async:true,
				dataType: "json",
				data: ({
					action: act,
					ordcom_id: id
				}),
				beforeSend: function() {					
				},
				success: function(data){
				
					toastr["info"](data.ordcom_msj);	
				},
				complete: function(){
					
					ordencompra_tabla();
				}
			});
		}
		else
		{			
			ordencompra_tabla();	
		}
	}

	
$(function() {

			ordencompra_filtro();
			

			$('#btn_actualizar').click(function() {
				$("#contenido").load("../ordencompra/ordencompra_vista.php");
			});
			
			$("#div_cliente_form_dialog").on('hidden.bs.modal', function () {
		   	$('body').css('overflow-y','hidden');
			});
			
			
			$("#div_venta_form_dialog").on('hidden.bs.modal', function () {
		   	$('body').css('overflow-y','scroll');
			
			});
			
			$("#div_ordencompra_form_dialog").on('hidden.bs.modal', function () {
		   	$('body').css('overflow-y','scroll');
			});
			
			$("#div_compra_form_dialog").on('hidden.bs.modal', function () {
		   	$('body').css('overflow-y','scroll');
			});
	
			$("#div_mensaje_dialog").on('hidden.bs.modal', function () {
			$('body').css('padding-right','0px');
			});
	
			setTitle("ORDEN DE COMPRA - "+nombreEmpresa);

		});
	</script>

