<?php
include("DMMYSQLG.php");


//echo "EN CONSTRUCCION";
  //  exit(0);
 // echo date('Y-m-d H:i:s');
$sq_tippag = mysqli_query($con ,"select * from dgtippag WHERE codigo!=0");//Datos para combo setipven 
echo mysqli_error($con);
$ids = $_POST['bot'];

 array_splice($ids, 0, 1);
 
if(((count($ids)==1)&&$ids[0]=='')||(count($ids)>1)||(count($ids)<1)){    
    echo "SELECCIONE UN SOLO FOLIO";
    exit(0);
}



$sq_tiket = mysqli_query($con ,"select * from dgger_cajerosd where n_rec=(select n_rec from dgger_cajerosj where pedido=".$ids[0].");");//Datos para combo setipven 

echo "<form method='POST'>";

foreach ($_POST as $key => $value) {
    if ($key != 'isset') {
     echo "<input type='hidden' name='$key' value='$value'/>";
    }
}

while ($dt_tiket = mysqli_fetch_array($sq_tiket)){
?>

<input type="hidden" name="num_pag[]" value="<?php echo $dt_tiket['num_pag'];?>"/>
<table>
    <tr>
        
        
        <td>Tipo:</td>
        <td>
    	  <select name="tip_pag[]" id="setipven">
            
            	    <?php
 
						while ($dt_tippag = mysqli_fetch_array($sq_tippag)){
							if($dt_tippag['tip_pag'] == $dt_tiket['tip_pag']) 
								echo '<option value="'.$dt_tippag['tip_pag'].'" selected>'.$dt_tippag['desc_pag'].'</option>';
							else
								echo '<option value="'.$dt_tippag['tip_pag'].'">'.$dt_tippag['desc_pag'].'</option>';
						}
                                                mysqli_data_seek ($sq_tippag,0);
					?>
          	    </select>
    
    </td>        
    <td>REF:</td>
    <td><input type="text" value="<?=$dt_tiket['ref']?>" name="ref[]"/></td>
    <td>AUT</td>
    <td><input type="text" value="<?=$dt_tiket['aut']?>" name="aut[]"/></td>
     <td><?=$dt_tiket['importe']?></td>
           
 </tr>
 </table>
<?php
}
    
?>


<input type="submit" name="savechages"  value="Guardar"/>
</form>