<?php
$totalventa=0;
$totalpago=0;
?>
<style>
    td.custom-cell {
      background-color: #e2f0fb;    
    }
      /* Stylish excel 2007 */
        .ExcelTable2007 {
        	border: 1px solid #B0CBEF;
        	border-width: 1px 0px 0px 1px;
        	font-size: 12px;
        	font-family: Calibri;
        	font-weight: 100;
        	color:black;
        	border-spacing: 0px;
        	border-collapse: collapse;
        	
        }
        
        .ExcelTable2007 TH {
        	background-image: url(excel-2007-header-bg.gif);
        	background-repeat: repeat-x; 
        	font-weight: normal;
        	font-size: 13px;
        	border: 1px solid #9EB6CE;
        	border-width: 0px 1px 1px 0px;
        	height: 17px;
        	text-align:center;overflow: hidden;
          
          background: rgba(212,228,239,1);
          background: -moz-linear-gradient(top, rgba(212,228,239,1) 0%, rgba(212,228,239,1) 11%, rgba(212,228,239,1) 31%, rgba(183,195,204,1) 100%);
          background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(212,228,239,1)), color-stop(11%, rgba(212,228,239,1)), color-stop(31%, rgba(212,228,239,1)), color-stop(100%, rgba(183,195,204,1)));
          background: -webkit-linear-gradient(top, rgba(212,228,239,1) 0%, rgba(212,228,239,1) 11%, rgba(212,228,239,1) 31%, rgba(183,195,204,1) 100%);
          background: -o-linear-gradient(top, rgba(212,228,239,1) 0%, rgba(212,228,239,1) 11%, rgba(212,228,239,1) 31%, rgba(183,195,204,1) 100%);
          background: -ms-linear-gradient(top, rgba(212,228,239,1) 0%, rgba(212,228,239,1) 11%, rgba(212,228,239,1) 31%, rgba(183,195,204,1) 100%);
          background: linear-gradient(to bottom, rgba(212,228,239,1) 0%, rgba(212,228,239,1) 11%, rgba(212,228,239,1) 31%, rgba(183,195,204,1) 100%);
          filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d4e4ef', endColorstr='#b7c3cc', GradientType=0 );
        }
        
        .ExcelTable2007 TD {
            border: 0px;
        	background-color: white;
        	padding: 0px 4px 0px 2px;
        	border: 1px solid #D0D7E5;
        	border-width: 0px 1px 1px 0px;
        	text-align: left;
        	height:1px;
        	overflow: hidden;
        }
        
        .ExcelTable2007 TD {
        	border: 0px;
        	background-color: white;
        	padding: 0px 4px 0px 2px;
        	border: 1px solid #D0D7E5;
        	border-width: 0px 1px 1px 0px;
        	text-align: left;
        	height:1px;
        	overflow: hidden;
        }
        .ExcelTable2007 TD B {
        	border: 0px;
        	background-color: white;
        	font-weight: bold;
        	height:2px;
        	overflow: hidden;
        	text-align: right;
        }
        
        .ExcelTable2007 TD.heading {
        	background-color: #E4ECF7;
        	text-align: center;
        	border: 1px solid #9EB6CE;
        	border-width: 0px 1px 1px 0px;overflow: hidden;
        	
        }
        
        .ExcelTable2007 TH.heading {
        	background-image: url(excel-2007-header-left.gif);
        	background-repeat: none;
        	font-weight: bold;overflow: hidden;
        }
        .ExcelTable2007 TR {
        	height:2px;
        }

      
  </style>
<div id="content">
	<div class="panel box-shadow-none content-header">
		<div class="panel-body">
			<div class="col-md-12">
				<h3 class="animated fadeInLeft">Conciliación</h3>
				<p class="animated fadeInDown">
					Home <span class="fa-angle-right fa"></span> Formulario de conciliación
				</p>
			</div>
		</div>
	</div>
	<div class="form-element">
		<div class="col-md-12 padding-0">
			<div class="col-md-8">
			    <?php $session = \Config\Services::session();  if(!empty($session->getFlashdata('mensaje_malo'))):?>
    				<div class="alert alert-danger alert-dismissible show" role="alert">
    					<button type="button" class="close" data-dismiss="alert" aria-label="Close">
    						<span aria-hidden="true">&times;</span>
    					</button>
    					<?php echo $session->getFlashdata('mensaje_malo'); ?>
    				</div>
    			<?php endif;?>
    			<?php $session = \Config\Services::session();  if(!empty($session->getFlashdata('mensaje_bueno'))):?>
        			<div class="alert alert-success alert-dismissible show" role="alert">
        				<button type="button" class="close" data-dismiss="alert" aria-label="Close">
        					<span aria-hidden="true">&times;</span>
        				</button>
        				<?php echo $session->getFlashdata('mensaje_bueno'); ?>
        			</div>
    		    <?php endif;?>
				<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
					<div class="panel panel-default form-element-padding">
						<div class="panel-heading" role="tab" id="headingOne">
							<h4 class="panel-title">
								<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="false" aria-controls="collapseOne">
									<h4>Filtro</h4>
								</a>
							</h4>
						</div>
						<div id="collapseOne" class="panel-collapse collapse " role="tabpanel" aria-labelledby="headingOne">
							<div class="panel-body" style="padding-bottom:30px;">
								
						<div class="col-md-12">
							<form class="cmxform" id="signupForm" method="post" action="<?php echo base_url("conciliacion/filtro"); ?>">
								<div class="col-md-6">
                                    <div class="panel">
							        <div class=" panel-heading text-center"><h4>Pagos</h4></br>
									<div class="form-group form-animate-text">
										<input type="date" class="form-text" id="fechapago" name="fechapago" value="<?php echo $fechapago ;?>" onchange="fechapago()">
										<span class="bar"></span>
										<label>&nbsp;&nbsp;&nbsp;<span class="fa fa-calendar"></span> Seleccione la fecha de pago</label>
										<input type="date" class="form-text" id="fechapagofin" name="fechapagofin" value="<?php echo $fechapago ;?>">
										<span class="bar"></span>
										<label>&nbsp;&nbsp;&nbsp;<span class="fa fa-calendar"></span> Seleccione la fecha de pago</label>
									</div>
                                    
                                    <div class="form-group form-animate-text">
										<input type="date" class="form-text" id="fechapagoventa" name="fechapagoventa" value="<?php echo $fechapago ;?>" onchange="fechapago()">
										<span class="bar"></span>
										<label>&nbsp;&nbsp;&nbsp;<span class="fa fa-calendar"></span> Seleccione la fecha de transacción</label>
										<input type="date" class="form-text" id="fechapagoventafin" name="fechapagoventafin" value="<?php echo $fechapago;?>">
										<span class="bar"></span>
										<label>&nbsp;&nbsp;&nbsp;<span class="fa fa-calendar"></span> Seleccione la fecha de transacción</label>
									</div>
									</div></div></br>
									<div class="panel ">
							        <div class=" panel-heading text-center"><h4> Ventas</h4></br>
									<div class="form-group form-animate-text">
										<input type="date" class="form-text" id="fechatransaccion" name="fechatransaccion" value="<?php echo $fechatransaccion ;?>">
										<span class="bar"></span>
										<label>&nbsp;&nbsp;&nbsp;<span class="fa fa-calendar"></span> Seleccione la fecha de la venta</label>
										<input type="date" class="form-text" id="fechatransaccionfin" name="fechatransaccionfin" value="<?php echo $fechatransaccion ;?>" onchange="fechatransaccion()">
										<span class="bar"></span>
										<label>&nbsp;&nbsp;&nbsp;<span class="fa fa-calendar"></span> Seleccione la fecha de la venta</label>
									</div>
                                    </div></div>
									
									
								</div>

								<div class="col-md-6">
								    <div class="form-group form-animate-text" style="margin-top:40px !important;">
										<input type="text" class="form-text" id="lote" name="lote" value="<?php echo $lote ;?>">
										<span class="bar"></span>
										<label>Lote</label>
									</div>

									<div class="form-group form-animate-text" style="margin-top:40px !important;">
										<input type="text" class="form-text" id="autorizacion" name="autorizacion" value="<?php echo $autorizacion ;?>">
										<span class="bar"></span>
										<label>Autorización</label>
									</div>
									<div class="form-group form-animate-text" style="margin-top:40px !important;">
										<input type="text" class="form-text" id="valormin" name="valormin" value="<?php echo $valormin ;?>">
										<span class="bar"></span>
										<label>Valor mínimo</label>
									</div>

									<div class="form-group form-animate-text" style="margin-top:40px !important;">
										<input type="text" class="form-text" id="valormax" name="valormax" value="<?php echo $valormax ;?>">
										<span class="bar"></span>
										<label>Valor máximo</label>
									</div>
									<div class="form-group form-animate-text" style="margin-top:40px !important;">
										<input type="text" class="form-text" id="centrocosto" name="centrocosto" value="<?php echo $centrocosto ;?>">
										<span class="bar"></span>
										<label>Centro de costo</label>
									</div>
									
								</div>         
								</br></br></br>
								<div class="col-md-12">

									<input class="submit btn btn-danger" type="submit" value="Buscar">
								</div>
								
							</form>

						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	<div class="col-md-4">	
		<div class="panel-group" id="accordion1" role="tablist" aria-multiselectable="true">
			<div class="panel panel-default">
				<div class="panel-heading" role="tab" id="headingOne1">
					<h4 class="panel-title">
						<a role="button" data-toggle="collapse" data-parent="#accordion1" href="#collapseOne1" aria-expanded="false" aria-controls="collapseOne1">
							<h4>Desconciliación</h4>
						</a>
					</h4>
				</div>
				<div id="collapseOne1" class="panel-collapse collapse " role="tabpanel" aria-labelledby="headingOne1">
					<div class="panel-body">
						<form id="formulariodesconciliacion" class="cmxform"  method="post" action="<?php echo base_url("conciliacion/desconciliar"); ?>">
						    <div class="">
							<div class="form-group form-animate-text col-sm-6" style="margin-top:40px !important;">
								<input type="number" class="form-text" id="numeroconciliacion" name="numeroconciliacion" required >
								<span class="bar"></span>
								<label>Número de conciliación</label>
							</div>
							</br></br>
							<div class="col-sm-6">							
								<input class=" btn btn-primary" type="button" value="Buscar" onclick="buscarConciliacion()">
							</div>
							</div>
							
							
							<div id='datosConciliacion' class=" col-sm-12 padding-0" style="padding: 0; margin: 0; box-sizing: border-box;overflow-x: auto;">
					    
            			    </div>
						</form>
						<form id="formulariodesconciliacionfechacruce" class="cmxform"  method="post" action="<?php echo base_url("conciliacion/desconciliarFechaCruce"); ?>">
						    <div class="">
							<div class="form-group form-animate-text col-sm-6" style="margin-top:40px !important;">
								<input type="date" class="form-text" id="fechaconciliacion" name="fechaconciliacion" required >
								<span class="bar"></span>
								<label>Número de conciliación</label>
							</div>
							</br></br>
							<div class="col-sm-12"><input class="submit btn btn-danger" type="submit" value="Desconciliar" onclick=""></div>
							</div>
							
							
							
					    
            			    </div>
						</form>
						
				   
				    
					</div>
					
				</div>
				
				
				
			</div>
		</div>
	</div>








	<form id="formularioconciliacionmanial"  class="cmxform"  method="post" action="<?php echo base_url("conciliacion/conciliacionmanual"); ?>">
		<div class="col-md-6">
			<div class="panel form-element-padding">
				<div class="panel-heading">
					<h4>Tabla Ventas</h4>

					<h4>Sumatoria:  <label id="sum"><b>0.00</b></label> </h4>

				</div>
				<div class="panel-body" style="padding-bottom:30px;">
					<div class="col-md-12">
						<div class="responsive-table">
							<table id="tablaventa" class="ExcelTable2007" width="100%" cellspacing="0">
								<thead>
									<tr>
										<th>
											<div class="custom-control custom-checkbox">
												<input type="checkbox" class="custom-control-input" id="customCheck1" checked disabled>	
											</div>
										</th>
										<th>#</th>
										<th>Banco</th>
										<th>Fecha transacción</th>
										<th>Monto</th>
										<th>Lote</th>
										<th>Autorización</th>												
										<th>Tipo de tarjeta</th>
										<th>Centro de costo</th>
										<th></th>
									</tr>
								</thead>
								<tbody>
									<?php  if(!empty($datos_venta)):?>
										<?php  $i=1; foreach($datos_venta as $item):?>
										<tr>

											<td>
												<?php 
												$item1= base64_encode(serialize($item)); 
												
												?>
												<div class="custom-control custom-checkbox">
													<input type="checkbox" class="custom-control-input" id="valor_tabla_venta[]" name="valor_tabla_venta[]" onchange="sumatoria_venta(this.value)" value="<?php echo $item1;?>">	
												</div>
											</td>
											<td><?php echo $i ;?></td>
											<td><?php echo $item['ven_banco'];?></td>
											<td><?php echo $item['ven_fecha_transaccion'];?></td>
											<td style="text-align:right;"><?php echo $item['ven_monto']; $totalventa+=$item['ven_monto'];?></td>
											<td><?php echo $item['ven_lote'];?></td>
											<td><?php echo $item['ven_autorizacion'];?></td>
											<td><?php echo $item['ven_tarjeta_credito'];?></td>
											<td><?php echo $item['a'].$item['b'];?></td>
											<td><a href="#" data-toggle="modal" data-target="#editarmodal" onclick="editarobservacionventa('<?php echo $item['ven_id'];?>','<?php echo $item['ven_observacion'];?>');">
                                                <button class="btn btn-3d btn-info btn-xs" type="button" >
                                                  <i class="fa fa-eye"></i>                        
                                                </button>
                                              </a></td>
										</tr>
										<?php $i=$i+1; endforeach;?>
									<?php endif;?>											
								</tbody>
								<tfoot>
								    <tr>
								        <th colspan="4"></th>
								        <th><?php echo $totalventa; ?></th>
								        <th colspan="4"></th>
								    </tr>
								</tfoot>
							</table>
						</div>	
					</div>
				</div>
			</div>
		</div>
		<div class="col-md-6">
			<div class="panel form-element-padding">
				<div class="panel-heading">
					<h4>Tabla Pagos</h4>
					<h4>Sumatoria:  <label id="sumpago"><b>0.00</b></label> </h4>
				</div>
				<div class="panel-body" style="padding-bottom:30px;">
					<div class="col-md-12">
						<div class="responsive-table">
							<table id="tablapago" class="ExcelTable2007" width="100%" cellspacing="0">
								<thead>
									<tr>
										<th>
											<div class="custom-control custom-checkbox">
												<input type="checkbox" class="custom-control-input" id="customCheck1" checked disabled>	
											</div>
										</th>
										<th>#</th>
										<th>Fecha pago</th>
										<th>Fecha transacción</th>
										<th>Monto</th>
										<th>Lote</th>
										<th>Autorización</th>	
										<th>Centro de costo</th>
										<th></th>
									</tr>
								</thead>
								<tbody>
									<?php  if(!empty($datos_pago_detalle)):?>
										<?php $i=1; foreach($datos_pago_detalle as $item):?>
										<tr>
											<td>
												<?php 
												$item1= base64_encode(serialize($item)); 
												?>
												<div class="custom-checkbox">
													<input type="checkbox" class="custom-control-input" id="valor_tabla_pago[]" name="valor_tabla_pago[]" onchange="sumatoria_pago(this.value)" value="<?php echo $item1;?>">	
												</div>
											</td>
											<td><?php echo $i ;?></td>
											<td><?php echo $item['pad_fecha_pago'];?></td>
											<td><?php echo $item['pad_fecha_transaccion'];?></td>
											<td style="text-align:right;"><?php echo $item['pad_total_pagar']; $totalpago+=$item['pad_total_pagar'];?></td>
											<td><?php echo $item['pad_lote'];?></td>
											<td><?php echo $item['pad_autorizacion'];?></td>
											<td><?php echo $item['cco_pdv'];?></td>
											<td><a href="#" data-toggle="modal" data-target="#editarpagomodal" onclick="editarobservacionpago('<?php echo $item['pad_id'];?>','<?php echo $item['pad_observacion'];?>');">
                                                <button class="btn btn-3d btn-info btn-xs" type="button" >
                                                  <i class="fa fa-eye"></i>                        
                                                </button>
                                              </a></td>
										</tr>
										<?php $i=$i+1; endforeach;?>	
									<?php endif;?>											
								</tbody>
								<tfoot>
								    <tr>
								        <th colspan="4"></th>
								        <th><?php echo $totalpago; ?></th>
								        <th colspan="3"></th>
								    </tr>
								</tfoot>
							</table>
						</div>
						
						<input type="hidden" id="tabla_dato_pago" name="tabla_dato_pago">
						
						<input type="hidden" id="tabla_dato_venta" name="tabla_dato_venta">
						
					</div>
				</div>
			</div>
		</div>
	</form>
	<div class="col-md-3">
		<div class="panel form-element-padding">					
		</div>
	</div>
	<div class="col-md-6">
		<div class="panel form-element-padding">
			<div class="panel-heading">
				<h4>Acciones</h4>
			</div>
			<div class="panel-body" style="padding-bottom:30px;">
				


				<div class="col-md-4">
					<br>							
					<form id="formularioconciliacionautomatica" class="cmxform"  method="post" action="<?php echo base_url("public/conciliacion/conciliacionautomatica"); ?>">		
						<?php if(!empty($datos_pago_detalle)):?> 
							<?php 
							$valores_datos_pago_detalle= base64_encode(serialize($datos_pago_detalle)); 
							?>
							<input type="hidden" id="dato_pago" name="dato_pago" value="<?php echo  $valores_datos_pago_detalle ?>">
						<?php endif;?>
						<?php if(!empty($datos_venta)):?> 
							<?php 
							$valores_datos_venta= base64_encode(serialize($datos_venta)); 
							?>
							<input type="hidden" id="dato_venta" name="dato_venta" value="<?php echo  $valores_datos_venta ?>">
						<?php endif;?>
						<input class="submit btn btn-danger" type="button" onclick="enviar_datos_php_conciliacion_manual()" value="Conciliación Manual">
						</br> </br> 
						<input class="submit btn btn-danger" type="button" onclick="enviar_datos_php_conciliacion_automatica()" value="Conciliación Automática">

					</form>				

				</div>

			</div>
		</div>
	</div>
</div>
</div>
</div>

<div class="modal fade" id="editarmodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <div class="modal-header">
              <h5 class="modal-title" id="exampleModalLabel">Observación</h5>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div class="modal-body">
              <form method="post" action="<?php echo base_url("/Conciliacion/editarObservacion"); ?>">
                <input type="hidden" id="editarvenid" name="editarvenid">
                <div class="form-group form-animate-text">
                  <input type="text" class="form-text" id="editarobservacionventa" name="editarobservacionventa">
                  <span class="bar"></span>
                  <label>Observación</label>
                </div>
                      
                <div class="modal-footer">
                  <button type="button" class="btn  btn-3d btn-danger" data-dismiss="modal">Cerrar</button>
                  <input type="submit" class="btn  btn-3d btn-success" value="Guardar"/>
                </div>
              </form>
            </div>

          </div>
        </div>
      </div>
      
<div class="modal fade" id="editarpagomodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <div class="modal-header">
              <h5 class="modal-title" id="exampleModalLabel">Observación</h5>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div class="modal-body">
              <form method="post" action="<?php echo base_url("/Conciliacion/editarObservacionPago"); ?>">
                <input type="hidden" id="editarpadid" name="editarpadid">
                <div class="form-group form-animate-text">
                  <input type="text" class="form-text" id="editarobservacionpago" name="editarobservacionpago">
                  <span class="bar"></span>
                  <label>Observación</label>
                </div>
                      
                <div class="modal-footer">
                  <button type="button" class="btn  btn-3d btn-danger" data-dismiss="modal">Cerrar</button>
                  <input type="submit" class="btn  btn-3d btn-success" value="Guardar"/>
                </div>
              </form>
            </div>

          </div>
        </div>
      </div>

 
 
      
<div class="modal fade" id="spinnerconciliacion" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" >
	<div class="modal-dialog" role="document" >
		<div class="modal-content" >     
			<div class="form-element" >
				<div class="col-md-12 padding-0" >
					<div class="col-md-12" >						
						<br><br><br><br><br><br><br><br><br><br>
						
						<div class="sk-fading-circle">
							<div class="sk-circle1 sk-circle"></div>
							<div class="sk-circle2 sk-circle"></div>
							<div class="sk-circle3 sk-circle"></div>
							<div class="sk-circle4 sk-circle"></div>
							<div class="sk-circle5 sk-circle"></div>
							<div class="sk-circle6 sk-circle"></div>
							<div class="sk-circle7 sk-circle"></div>
							<div class="sk-circle8 sk-circle"></div>
							<div class="sk-circle9 sk-circle"></div>
							<div class="sk-circle10 sk-circle"></div>
							<div class="sk-circle11 sk-circle"></div>
							<div class="sk-circle12 sk-circle"></div>
						</div>


						
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<script>
    function fechapago()
    {
        var min=document.getElementById("fechapago").value;
        alert(min);
        document.getElementById("fechapagofin").setAttribute("min", min);
    }
    function fechatransaccion()
    {
        document.getElementById("fechatransaccionfin").setAttribute("min", document.getElementById("fechatransaccion").value);
    }
    
    function buscarConciliacion()
    {
        var link_url_ctc='https://megaprofer.serviciosrapidito.com/api-ctc/public/';
        var numero=document.getElementById("numeroconciliacion").value;
        //alert(numero);
        
        $.ajax({		    
				url : link_url_ctc+'relacionpagosventasverconciliacion',
				data : {rpv_id:numero},
				type : 'POST',
				dataType : 'json',


				success : function(json) {		    	
					var html ='<div class="col-sm-6" style="overflow-x: auto"><table id="tablaventa" class="stripe" style="width:100%; border: 1px solid black;"><thead style="width:100%; border: 1px solid black;"><tr><th colspan=4>VENTAS</th><tr><tr><th>Fecha</th><th>Monto</th><th>Autorización</th><th>Lote</th><tr></thead><tbody style="width:100%; border: 1px solid black;">';
					if(json['data']!=null){
						for(var i =0;i<json['data']['ventas'].length ; i++){	
						    html +='<tr><td>'+ json['data']['ventas'][i]['ven_fecha_transaccion']+'</td><td>'+ json['data']['ventas'][i]['ven_monto']+'</td><td>'+ json['data']['ventas'][i]['ven_autorizacion']+'</td><td>'+ json['data']['ventas'][i]['ven_lote']+'</td></tr>';
							
						}
    					html +='</table></div>';
    					html +='<div class="col-sm-6" style="overflow-x: auto"><table id="tablapago" class="stripe" style="width:100%; border: 1px solid black;"><thead style="width:100%; border: 1px solid black;"><tr><th colspan=4>PAGOS</th><tr><tr><th>Fecha</th><th>Monto</th><th>Autorización</th><th>Lote</th><tr></thead><tbody style="width:100%; border: 1px solid black;">';
    					if(json['data']!=null){
    						for(var i =0;i<json['data']['pagos'].length ; i++){	
    						    html +='<tr><td>'+ json['data']['pagos'][i]['pad_fecha_pago']+'</td><td>'+ json['data']['pagos'][i]['pad_total_pagar']+'</td><td>'+ json['data']['pagos'][i]['pad_autorizacion']+'</td><td>'+ json['data']['pagos'][i]['pad_lote']+'</td></tr>';
    							
    						}
    					}
    					console.log(Object.values(json['data'])) ;
    					
    					html +='</table></div> </br></br> <div class="col-sm-12"><input class="submit btn btn-danger" type="button" value="Desconciliar" onclick="comprobardesconciliar()"></div>';
    					$('#datosConciliacion').html(html);
					}
					else
					{
					    html +='';
					    $('#datosConciliacion').html(html);
					}
					
				},

				error : function(xhr, status) {
					alert('Disculpe, existió un problema');
				},


			});
    }
    
    function buscarConciliacionFechaCruce()
    {
        var link_url_ctc='https://megaprofer.serviciosrapidito.com/api-ctc/public/';
        var numero=document.getElementById("fechaconciliacion").value;
        //alert(numero);
        
        $.ajax({		    
				url : link_url_ctc+'relacionpagosventasverconciliacionfechacruce',
				data : {rpv_fecha_cruce:numero},
				type : 'POST',
				dataType : 'json',


				success : function(json) {		    	
					var html ='<div class="col-sm-6" style="overflow-x: auto"><table id="tablaventa" class="stripe" style="width:100%; border: 1px solid black;"><thead style="width:100%; border: 1px solid black;"><tr><th colspan=4>VENTAS</th><tr><tr><th>Fecha</th><th>Monto</th><th>Autorización</th><th>Lote</th><tr></thead><tbody style="width:100%; border: 1px solid black;">';
					if(json['data']!=null){
						for(var i =0;i<json['data']['ventas'].length ; i++){	
						    html +='<tr><td>'+ json['data']['ventas'][i]['ven_fecha_transaccion']+'</td><td>'+ json['data']['ventas'][i]['ven_monto']+'</td><td>'+ json['data']['ventas'][i]['ven_autorizacion']+'</td><td>'+ json['data']['ventas'][i]['ven_lote']+'</td></tr>';
							
						}
    					html +='</table></div>';
    					html +='<div class="col-sm-6" style="overflow-x: auto"><table id="tablapago" class="stripe" style="width:100%; border: 1px solid black;"><thead style="width:100%; border: 1px solid black;"><tr><th colspan=4>PAGOS</th><tr><tr><th>Fecha</th><th>Monto</th><th>Autorización</th><th>Lote</th><tr></thead><tbody style="width:100%; border: 1px solid black;">';
    					if(json['data']!=null){
    						for(var i =0;i<json['data']['pagos'].length ; i++){	
    						    html +='<tr><td>'+ json['data']['pagos'][i]['pad_fecha_pago']+'</td><td>'+ json['data']['pagos'][i]['pad_total_pagar']+'</td><td>'+ json['data']['pagos'][i]['pad_autorizacion']+'</td><td>'+ json['data']['pagos'][i]['pad_lote']+'</td></tr>';
    							
    						}
    					}
    					console.log(Object.values(json['data'])) ;
    					
    					html +='</table></div> </br></br> <div class="col-sm-12"><input class="submit btn btn-danger" type="button" value="Desconciliar" onclick="comprobardesconciliar()"></div>';
    					$('#datosConciliacion').html(html);
					}
					else
					{
					    html +='';
					    $('#datosConciliacion').html(html);
					}
					
				},

				error : function(xhr, status) {
					alert('Disculpe, existió un problema');
				},


			});
    }
    
</script>
<script>
    editarobservacionventa=function(ven_id, ven_observacion){
        $('#editarvenid').val(ven_id);
		$('#editarobservacionventa').val(ven_observacion);
    }
    editarobservacionpago=function(pad_id, pad_observacion){
        $('#editarpadid').val(pad_id);
		$('#editarobservacionpago').val(pad_observacion);
    }
</script>