Esempio n. 1
0
function previo_sap($fechai, $fechaf, $aplica_oes, $buscar, $filtros, $stock)
{
    ?>
    
<table align="center" border="1">
<thead>
<tr height="20">
	<td align="center" bgcolor="#FFCC33">No.Item</td>
    <td align="center" bgcolor="#FFCC33">Fecha</td>
	<td align="center" bgcolor="#FFCC33">Txs SAP</td>
	<td align="center" bgcolor="#FFCC33">Mov</td>
	<td align="center" bgcolor="#FFCC33">Código Scrap</td>
	<td align="center" bgcolor="#FFCC33">O.I.</td>
    <td align="center" bgcolor="#FFCC33">APD</td>
	<td align="center" bgcolor="#FFCC33">Parte Padre</td>
	<td align="center" bgcolor="#FFCC33">Batch ID</td>
	<td align="center" bgcolor="#FFCC33">No.Parte</td>
	<td align="center" bgcolor="#FFCC33">Cantidad</td>
	<td align="center" bgcolor="#FFCC33">Reason Code</td>
	<td align="center" bgcolor="#FFCC33">Descripción</td>
	<td align="center" bgcolor="#FFCC33">Info.Obl.</td>
	<td align="center" bgcolor="#FFCC33">Tipo</td>
    <td align="center" bgcolor="#FFCC33">Tipo Sub</td>
	<td align="center" bgcolor="#FFCC33">Valor</td>
	<td align="center" bgcolor="#FFCC33">Doc. Header Tex</td>
    <td align="center" bgcolor="#FFCC33">Déficit Stock</td>
	<td align="center" bgcolor="#FFCC33">No.Docto.SAP</td>
</tr>
</thead>
<tbody>
<?php 
    $s_f = "select folios.*, partes.id as idp, partes.no_parte, partes.descripcion, partes.cantidad, partes.total as costo_total, ";
    $s_f .= "partes.ubicacion, partes.docto_sap, partes.deficit, partes.tipo, partes.tipo_sub, partes.padre, partes.batch_id, ";
    $s_f .= "partes.serial_unidad from scrap_partes as partes, scrap_folios as folios, autorizaciones, numeros_parte where folios.no_folio = partes.no_folio and ";
    $s_f .= "autorizaciones.no_folio = folios.no_folio and folios.status='1' and folios.activo='1' and (partes.docto_sap='0' or partes.docto_sap='') ";
    $s_f .= "and partes.no_parte = numeros_parte.nombre ";
    if ($stock == '1') {
        $s_f .= " and partes.deficit='1' ";
    }
    if ($stock != '1') {
        $s_f .= " and partes.deficit like '%' ";
    }
    for ($i = 0; $i <= 2; $i++) {
        if ($buscar[$i] != '' && $filtros[$i] != '') {
            $s_f .= " and ( ";
            $data = split(",", $buscar[$i]);
            for ($j = 0; $j < count($data); $j++) {
                $s_f .= get_operador($filtros[$i], $data[$j]) . " or ";
            }
            $s_f = substr($s_f, 0, -3) . " ) ";
        }
    }
    if ($aplica_oes == 'si') {
        $s_f .= " and autorizaciones.depto = 'oes' ";
    }
    if ($fechai != '' && $fechaf != '') {
        $s_f .= "and (fecha>='{$fechai}' and fecha<='{$fechaf}') ";
    }
    if ($_SESSION["TYPE"] != 'autorizador') {
        $s_f .= filtros_capturista();
    }
    if ($_SESSION["TYPE"] == 'autorizador') {
        $s_f .= filtros_autorizador();
    }
    $s_f .= "group by partes.id order by folios.no_folio asc ";
    $r_1 = mysql_query($s_f);
    while ($d_1 = mysql_fetch_array($r_1)) {
        ?>
<tr>
	<td align="center"><?php 
        echo $d_1['no_folio'];
        ?>
</td>
    <td align="center"><?php 
        echo $d_1['fecha'];
        ?>
</td>
	<td align="center"><?php 
        echo $d_1['txs_sap'];
        ?>
</td>
	<td align="center"><?php 
        echo $d_1['mov_sap'];
        ?>
</td>
	<td align="left">
	<?php 
        $original = data_codigo_original($d_1['no_folio'], $d_1['financiero']);
        if ($d_1['financiero'] == '0') {
            echo $d_1['codigo_scrap'];
        } else {
            echo $original['codigo'];
        }
        ?>
</td>
	<td align="left"><?php 
        echo $d_1['orden_interna'];
        ?>
</td>
    <td align="left"><?php 
        echo "'" . $d_1['apd'];
        ?>
</td>
    <td align="left"><?php 
        echo $d_1['padre'];
        ?>
</td>
	<td align="left"><?php 
        echo $d_1['batch_id'];
        ?>
</td>
	<td align="left"><?php 
        echo $d_1['no_parte'];
        ?>
</td>
	<td align="center"><?php 
        echo $d_1['cantidad'];
        ?>
</td>
	<td align="left"><?php 
        echo $d_1['reason_code'];
        ?>
</td>
	<td align="left"><?php 
        echo $d_1['descripcion'];
        ?>
</td>
	<td align="left"><?php 
        echo $d_1['info_1'] . $d_1['info_2'];
        ?>
</td>
	<td align="center"><?php 
        echo $d_1['tipo'];
        ?>
</td>
    <td align="center"><?php 
        if ($d_1['tipo'] == 'HALB') {
            echo $d_1['tipo_sub'];
        } else {
            echo "NA";
        }
        ?>
</td>
	<td align="right"><?php 
        echo $d_1['costo_total'];
        ?>
</td>
	<td align="left"><?php 
        echo get_doc_header($d_1['info_1'], $d_1['info_2'], $d_1['segmento'], $d_1['proyecto'], $d_1['no_folio']);
        ?>
</td>
    <td align="center"><?php 
        if ($d_1['deficit'] == '1') {
            echo "SI";
        } else {
            echo "NO";
        }
        ?>
</td>
	<td align="center">&nbsp;</td>
</tr>	
<?php 
    }
    ?>
</tbody>
</table>
<?php 
}
Esempio n. 2
0
function listado($fechai, $fechaf, $proy_add, $proy_del, $aplica_oes, $buscar, $filtros, $stock, $pagina)
{
    if (!$aplica_oes) {
        $aplica_oes = 'no';
    }
    if (!$pagina) {
        $pagina = 1;
    }
    if (count($proy_add) > 0) {
        for ($i = 0; $i < count($proy_add); $i++) {
            $s_1 = "insert into filtros values('','proyectos','{$proy_add[$i]}','{$_SESSION['IDEMP']}')";
            $r_1 = mysql_query($s_1);
        }
    }
    if (count($proy_del) > 0) {
        for ($i = 0; $i < count($proy_del); $i++) {
            $s_1 = "delete from filtros where filtro='proyectos' and id_emp='{$_SESSION['IDEMP']}' and valor='{$proy_del[$i]}'";
            $r_1 = mysql_query($s_1);
        }
    }
    ?>
    
<div style="margin-left:100px;" class="titulo">
<table align="center" cellpadding="10" cellspacing="0" border="0">
<tr>
	<td class="titulo" width="270">REPORTE DE CAPTURA SAP</td>
	<td align="left">&nbsp;
	<span title="header=[&nbsp;&nbspReporte de captura SAP] body=[Este es el reporte previo a SAP donde se muestra todo el scrap aprobado que aún no tiene asignado un número de documento SAP.<br><br>Puede imprimir este reporte exportándolo directamente a excel e ingresar los números de documento SAP. Una vez guardado el número, no podrá modificarse.<br>]"><img src="../imagenes/question.gif" width="20" height="20"></span>	
	</td>	
</tr>
</table></div><hr>  

<div align="center" class="aviso">Si desea filtrar la información, utilice los calendarios y listas desplegables.</div>
<form action="?op=listado" method="post" name="form1">
<table align="center" class="tabla">
	<tr height="20">
		<td align="center" width="100" bgcolor="#E6E6E6">Inicio Captura</td>
		<td align="center" width="100" bgcolor="#E6E6E6">Fin Captura</td>
        <td align="center" bgcolor="#E6E6E6">Agregue/quite proyectos</td>
    </tr>
    <tr>
	<td align="center">
		<script language="JavaScript">
		var GC_SET_0 = {
		'appearance': GC_APPEARANCE,
		'dataArea': 'fechai',
		'valor': '<?php 
    echo $fechai;
    ?>
'
		}
		new gCalendar(GC_SET_0);
		</script>
	</td>
	<td align="center">
	  	<script language="JavaScript">
		var GC_SET_0 = {
		'appearance': GC_APPEARANCE,
		'dataArea': 'fechaf',
		'valor': '<?php 
    echo $fechaf;
    ?>
'
		}
		new gCalendar(GC_SET_0);
		</script>	
	</td>
	<td align="center">
    <table align="center" border="0" cellspacing="0" cellpadding="0" width="100%">
    <tr><td align="left">
	<?php 
    $r_1 = mysql_query(get_proyectos_out());
    $n_1 = mysql_num_rows($r_1);
    ?>
	<select name="proy_add[]" multiple="multiple" class="texto" id="proy_add_">
		<option value="">Seleccionar Todos</option>
		<?php 
    while ($d_1 = mysql_fetch_array($r_1)) {
        ?>
		<option value="<?php 
        echo $d_1['id'];
        ?>
"><?php 
        echo $d_1['nombre'];
        ?>
</option><?php 
    }
    ?>
	</select></td>
	<td align="center"><input type="button" value="<< >>" onclick="submit()" style="width:50px;" class="submit"></td>
	<td align="left">
	<?php 
    $r_1 = mysql_query(get_proyectos_in());
    $n_1 = mysql_num_rows($r_1);
    ?>
	<select name="proy_del[]" multiple="multiple" class="texto" id="proy_del_">
		<option value="">Seleccionar Todos</option>
		<?php 
    while ($d_1 = mysql_fetch_array($r_1)) {
        ?>
		<option value="<?php 
        echo $d_1['valor'];
        ?>
"><?php 
        echo $d_1['nombre'];
        ?>
</option><?php 
    }
    ?>
	</select></td>	
    </tr></table></td>
</tr>
</table><br>

<table align="center" class="tabla">
	<tr height="20">
		<td align="left" width="62">&nbsp;&nbsp;Buscar:</td>
   		<td>
        	<input type="text" class="texto" size="75" value="<?php 
    echo $buscar['0'];
    ?>
" name="buscar[0]" id="buscar">
        </td>
      	<td align="center">En:</td>
        <td><?php 
    $s_1 = "select campo, nombre from encabezados where de_captura='1' order by nombre";
    $r_1 = mysql_query($s_1);
    ?>
		<select name="filtros[0]" class="texto" style="width:150px;" id="filtros">
	  		<option value=""></option>	
			<?php 
    while ($d_1 = mysql_fetch_array($r_1)) {
        ?>
			<option value="<?php 
        echo $d_1['campo'];
        ?>
" <?php 
        if ($filtros[0] == $d_1['campo']) {
            ?>
 selected="selected"<?php 
        }
        ?>
>
			<?php 
        echo $d_1['nombre'];
        ?>
</option><?php 
    }
    ?>
		</select></td> 
		<td align="center" width="110">Filtrar por OES?</td>
	</tr> 
	<tr height="20">
		<td align="left" width="62">&nbsp;&nbsp;Buscar:</td>
   		<td>
        	<input type="text" class="texto" size="75" value="<?php 
    echo $buscar['1'];
    ?>
" name="buscar[1]" id="buscar">
        </td>
      	<td align="center">En:</td>
        <td><?php 
    $s_1 = "select campo, nombre from encabezados where de_captura='1' order by nombre";
    $r_1 = mysql_query($s_1);
    ?>
		<select name="filtros[1]" class="texto" style="width:150px;" id="filtros">
	  		<option value=""></option>	
			<?php 
    while ($d_1 = mysql_fetch_array($r_1)) {
        ?>
			<option value="<?php 
        echo $d_1['campo'];
        ?>
" <?php 
        if ($filtros[1] == $d_1['campo']) {
            ?>
 selected="selected"<?php 
        }
        ?>
>
			<?php 
        echo $d_1['nombre'];
        ?>
</option><?php 
    }
    ?>
		</select></td>
		<td align="center"><input type="radio" value="si" name="aplica_oes" <?php 
    if ($aplica_oes == 'si') {
        ?>
checked="checked"<?php 
    }
    ?>
 onclick='filtro_oes();'>&nbsp;&nbsp;SI</td>		
	</tr>    
	<tr height="20">
		<td align="left" width="62">&nbsp;&nbsp;Buscar:</td>
   		<td>
        	<input type="text" class="texto" size="75" value="<?php 
    echo $buscar['2'];
    ?>
" name="buscar[2]" id="buscar">
        </td>
      	<td align="center">En:</td>
        <td><?php 
    $s_1 = "select campo, nombre from encabezados where de_captura='1' order by nombre";
    $r_1 = mysql_query($s_1);
    ?>
		<select name="filtros[2]" class="texto" style="width:150px;" id="filtros">
	  		<option value=""></option>	
			<?php 
    while ($d_1 = mysql_fetch_array($r_1)) {
        ?>
			<option value="<?php 
        echo $d_1['campo'];
        ?>
" <?php 
        if ($filtros[2] == $d_1['campo']) {
            ?>
 selected="selected"<?php 
        }
        ?>
>
			<?php 
        echo $d_1['nombre'];
        ?>
</option><?php 
    }
    ?>
		</select></td> 
		<td align="center"><input type="radio" value="no" name="aplica_oes" <?php 
    if ($aplica_oes == 'no') {
        ?>
checked="checked"<?php 
    }
    ?>
 onclick='filtro_oes();'>&nbsp;&nbsp;NO</td>	
	</tr>         
</table>
<div align="center" class="texto"><br>
	<input type="checkbox" name="stock" value="1" <?php 
    if ($stock == '1') {
        ?>
 checked="checked"<?php 
    }
    ?>
>
    Mostrar sólo déficit de Stock&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="button" value="Buscar" class="submit" onclick="submit();">
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<input type="button" value="Exportar" class="submit" onclick="exportar();">
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<input type="button" value="Cargar Archivo" class="submit" onclick="upload();">
</div><br>

<?php 
    $s_f = "select folios.*, partes.id as idp, partes.no_parte, partes.descripcion, partes.cantidad, partes.total as costo_total, ";
    $s_f .= "partes.ubicacion, partes.docto_sap, partes.deficit, partes.tipo, partes.tipo_sub, partes.padre, partes.batch_id, ";
    $s_f .= "partes.serial_unidad from scrap_partes as partes, scrap_folios as folios, autorizaciones, numeros_parte where folios.no_folio = partes.no_folio and ";
    //$s_f.= "autorizaciones.no_folio = folios.no_folio and folios.status='1' and folios.activo='1' and (partes.docto_sap='0' or partes.docto_sap='') and ";
    $s_f .= "autorizaciones.no_folio = folios.no_folio and folios.status='1' and folios.activo='1' and (partes.docto_sap='0' or partes.docto_sap='') ";
    $s_f .= "and partes.no_parte = numeros_parte.nombre ";
    //$s_f.= "partes.tipo like '$f_material' ";
    if ($f_sub == "REAL") {
        $s_f .= " and partes.tipo_sub like 'S.Real'";
    }
    if ($f_sub == "AUTO") {
        $s_f .= " and partes.tipo_sub like '%AutoBF'";
    }
    if ($stock == '1') {
        $s_f .= " and partes.deficit='1' ";
    }
    if ($stock != '1') {
        $s_f .= " and partes.deficit like '%' ";
    }
    for ($i = 0; $i <= 2; $i++) {
        if ($buscar[$i] != '' && $filtros[$i] != '') {
            $s_f .= " and ( ";
            $data = split(",", $buscar[$i]);
            for ($j = 0; $j < count($data); $j++) {
                $s_f .= get_operador($filtros[$i], $data[$j]) . " or ";
            }
            $s_f = substr($s_f, 0, -3) . " ) ";
        }
    }
    if ($fechai != '' && $fechaf != '') {
        $s_f .= "and (fecha>='{$fechai}' and fecha<='{$fechaf}') ";
    }
    if ($aplica_oes == 'si') {
        $s_f .= " and autorizaciones.depto = 'oes' ";
    }
    if ($_SESSION["TYPE"] != 'autorizador') {
        $s_f .= filtros_capturista();
    }
    if ($_SESSION["TYPE"] == 'autorizador') {
        $s_f .= filtros_autorizador();
    }
    $s_f .= "group by partes.id order by folios.no_folio asc ";
    $r_1 = mysql_query($s_f);
    $tot = mysql_num_rows($r_1);
    $pags = ceil($tot / 100);
    $ini_ = ($pagina - 1) * 100;
    $i = 1;
    $j = 0;
    $ruta = "&fechai={$fechai}&fechaf={$fechaf}&reason={$reason}&buscar[0]={$buscar['0']}&filtros[0]={$filtros['0']}";
    $ruta .= "&buscar[1]={$buscar['1']}&filtros[1]={$filtros['1']}&buscar[2]={$buscar['2']}&filtros[2]={$filtros['2']}&stock={$stock}";
    if ($tot > 0) {
        ?>
     
<table align="center" border="0" class="texto" cellpadding="0" cellspacing="0">
<tr>
	<td width="110" align="center" bgcolor="#BDBDBD" class="link_paginas"><?php 
        echo $tot;
        ?>
 Registros</td>
	<td align="center" valign="top" bgcolor="#BDBDBD">
    <table align="center" border="0" class="texto" cellpadding="0" cellspacing="2">
	<?php 
        while ($i <= $pags) {
            if ($j >= 30) {
                echo "</tr>";
                $j = 0;
            }
            if ($j == 0) {
                echo "<tr height='20'>";
            }
            if ($pagina == $i) {
                $color = '#FFBF00';
            } else {
                $color = '#F2F2F2';
            }
            ?>
    <td width="30" align="center" bgcolor="<?php 
            echo $color;
            ?>
">
    	<a href="?op=listado<?php 
            echo $ruta;
            ?>
&pagina=<?php 
            echo $i;
            ?>
" class="link_paginas"><?php 
            echo $i;
            ?>
</a></td>
	<?php 
            $i++;
            $j++;
        }
        ?>
    </table>
    </td>
</tr>    
</table><br><?php 
    }
    ?>

<table align="center" class="tabla">
<thead>
<tr bgcolor="#E6E6E6" height="20">
	<td align="center">No.Item</td>
    <td align="center">Fecha</td>
	<td align="center">Txs SAP</td>
	<td align="center">Mov</td>
	<td align="center">Código Scrap</td>
    <td align="center">Código Original</td>
	<td align="center">O.I.</td>
    <td align="center">APD</td>
    <td align="center">Proyecto</td>
	<td align="center">Parte Padre</td>
	<td align="center">Batch ID</td>
	<td align="center">No.Parte</td>
	<td align="center">Cantidad</td>
	<td align="center">Reason Code</td>
	<td align="center">Descripción</td>
	<td align="center">Info.Obl.</td>
	<td align="center">Tipo</td>
    <td align="center">Tipo Sub</td>
	<td align="center" width="70">Valor</td>
	<td align="center" width="70">Doc. Header Tex</td>
	<td align="center">No.Docto.SAP</td>
    <td align="center">Docto.Déficit</td>
    <td align="center" width="50">Déficit Stock</td>
</tr>
</thead>
<tbody>
<?php 
    $mouse_over = "this.style.background='#FFDD99'";
    $mouse_out = "this.style.background='#F7F7F7'";
    $s_f .= " limit {$ini_}, 100";
    $r_1 = mysql_query($s_f);
    $i = 0;
    $total = mysql_num_rows($r_1);
    while ($d_1 = mysql_fetch_array($r_1)) {
        echo "<tr onMouseOut=\"{$mouse_out}\" onMouseOver=\"{$mouse_over}\" bgcolor=\"#F7F7F7\" height=\"20\">";
        ?>
	  	<td align="center"><?php 
        echo $d_1['no_folio'];
        ?>
</td>
        <td align="center"><?php 
        echo $d_1['fecha'];
        ?>
</td>
		<td align="center"><?php 
        echo $d_1['txs_sap'];
        ?>
</td>
		<td align="center"><?php 
        echo $d_1['mov_sap'];
        ?>
</td>
		<td align="center"><?php 
        echo $d_1['codigo_scrap'];
        ?>
</td>
		<td align="center">
		<?php 
        if ($d_1['financiero'] == '1') {
            $original = data_codigo_original($d_1['no_folio'], $d_1['financiero']);
            echo $original['codigo'];
        } else {
            echo "NA";
        }
        ?>
</td>
		<td align="left"><?php 
        echo $d_1['orden_interna'];
        ?>
</td>
        <td align="left"><?php 
        echo $d_1['apd'];
        ?>
</td>
        <td align="left"><?php 
        echo $d_1['proyecto'];
        ?>
</td>
		<!--<td align="left"><?php 
        echo iconv("UTF-8", "ISO-8859-1", $d_1['padre']);
        ?>
</td>-->
        <td align="left"><?php 
        echo $d_1['padre'];
        ?>
</td>
		<td align="center"><?php 
        echo $d_1['batch_id'];
        ?>
</td>
		<td align="left"><?php 
        echo $d_1['no_parte'];
        ?>
</td>
		<td align="center"><?php 
        echo $d_1['cantidad'];
        ?>
</td>
		<td align="left"><?php 
        echo $d_1['reason_code'];
        ?>
</td>
		<td align="left"><?php 
        echo $d_1['descripcion'];
        ?>
</td>
		<td align="left"><?php 
        echo $d_1['info_1'] . $d_1['info_2'];
        ?>
</td>
		<td align="center"><?php 
        echo $d_1['tipo'];
        ?>
</td>
    	<td align="center"><?php 
        if ($d_1['tipo'] == 'HALB') {
            echo $d_1['tipo_sub'];
        } else {
            echo "NA";
        }
        ?>
</td>
		<td align="right"><?php 
        echo "\$ " . number_format($d_1['costo_total'], 2);
        ?>
</td>
		<td align="left"><?php 
        echo get_doc_header($d_1['info_1'], $d_1['info_2'], $d_1['segmento'], $d_1['proyecto'], $d_1['no_folio']);
        ?>
</td>
		<td align="center">
        	<input type="hidden" name="id_[<?php 
        echo $i;
        ?>
]" class="texto" size="15" id="id_" value="<?php 
        echo $d_1['idp'];
        ?>
">
            <input type="text" name="sap[<?php 
        echo $d_1['idp'];
        ?>
]" class="texto" size="15" id="sap" onkeypress="return solo_numeros(event);"></td>
        <td align="center">    
        <select name="docto_def[<?php 
        echo $d_1['idp'];
        ?>
]" class="texto" style="width:107px;" id="docto_def" <?php 
        if ($d_1['deficit'] == '0') {
            ?>
 disabled="disabled"<?php 
        }
        ?>
>
        	<option value=""></option>
            <?php 
        $s_ = "select * from motivos_sap where activo='1' order by motivo";
        $r_ = mysql_query($s_);
        while ($d_ = mysql_fetch_array($r_)) {
            ?>
            <option value="<?php 
            echo $d_['id'];
            ?>
" <?php 
            if ($d_['docto_sap'] == $d_['motivo']) {
                ?>
 selected="selected"<?php 
            }
            ?>
><?php 
            echo $d_['motivo'];
            ?>
</option>
            <?php 
        }
        ?>
        </select></td>
  		<td align="center">
            <input type="checkbox" name="deficit[<?php 
        echo $d_1['idp'];
        ?>
]" value="1" <?php 
        if ($d_1['deficit'] == '1') {
            ?>
 checked="checked"<?php 
        }
        ?>
 onclick="deficit_('<?php 
        echo $i;
        ?>
','<?php 
        echo $total;
        ?>
');" id="deficit"></td>
</tr>	
<?php 
        $i++;
    }
    ?>
</tbody>
</table>
<br><div align="center">
	<input type="button" class="submit" value="Guardar" onclick="guardar('<?php 
    echo $total;
    ?>
');">
</div></form><br><br>
<?php 
}
Esempio n. 3
0
function ver($fechai, $fechaf, $proy_add, $proy_del, $aplica_oes, $buscar, $filtros, $stock, $pagina, $f_material, $f_sub, $f_txs, $pag, $bandera)
{
    if (!$pag) {
        $pag = '1';
    }
    if (!$bandera) {
        $s_1 = "delete from tmp_vertical where id_emp='{$_SESSION['IDEMP']}'";
        $r_1 = mysql_query($s_1);
        $s_f = "select folios.*, partes.id as idp, partes.no_parte, partes.descripcion, partes.cantidad, partes.total as costo_total, ";
        $s_f .= "partes.ubicacion, partes.docto_sap, partes.deficit, partes.tipo, partes.tipo_sub, partes.padre, partes.batch_id, ";
        $s_f .= "partes.serial_unidad from scrap_partes as partes, scrap_folios as folios, autorizaciones, numeros_parte where folios.no_folio = partes.no_folio and ";
        $s_f .= "autorizaciones.no_folio = folios.no_folio and folios.status='1' and folios.activo='1' and (partes.docto_sap='0' or partes.docto_sap='') and ";
        $s_f .= "partes.tipo like '{$f_material}' and txs_sap like '{$f_txs}' and partes.no_parte = numeros_parte.nombre ";
        if ($f_sub == "REAL") {
            $s_f .= " and partes.tipo_sub like 'S.Real'";
        }
        if ($f_sub == "AUTO") {
            $s_f .= " and partes.tipo_sub like '%AutoBF'";
        }
        if ($stock == '1') {
            $s_f .= " and partes.deficit='1' ";
        }
        if ($stock != '1') {
            $s_f .= " and partes.deficit like '%' ";
        }
        for ($i = 0; $i <= 2; $i++) {
            if ($buscar[$i] != '' && $filtros[$i] != '') {
                $s_f .= " and ( ";
                $data = split(",", $buscar[$i]);
                for ($j = 0; $j < count($data); $j++) {
                    $s_f .= get_operador($filtros[$i], $data[$j]) . " or ";
                }
                $s_f = substr($s_f, 0, -3) . " ) ";
            }
        }
        if ($fechai != '' && $fechaf != '') {
            $s_f .= "and (fecha>='{$fechai}' and fecha<='{$fechaf}') ";
        }
        if ($aplica_oes == 'si') {
            $s_f .= " and autorizaciones.depto = 'oes' ";
        }
        if ($_SESSION["TYPE"] != 'autorizador') {
            $s_f .= filtros_capturista();
        }
        if ($_SESSION["TYPE"] == 'autorizador') {
            $s_f .= filtros_autorizador();
        }
        $s_f .= "group by partes.id order by folios.no_folio asc ";
        $r_1 = mysql_query($s_f);
        $i = 0;
        while ($d_1 = mysql_fetch_array($r_1)) {
            $total = $folios[$d_1['no_folio']];
            $header = get_doc_header($d_1['info_1'], $d_1['info_2'], $d_1['segmento'], $d_1['proyecto'], $d_1['no_folio'], $d_1['cantidad']);
            $s_ = "insert into tmp_vertical values ('', '{$_SESSION['IDEMP']}', '', '{$d_1['no_folio']}', '{$d_1['fecha']}', '{$d_1['txs_sap']}', '{$d_1['apd']}', ";
            $s_ .= "'{$d_1['padre']}', '{$d_1['no_parte']}','{$d_1['cantidad']}','{$d_1['costo_total']}', '{$d_1['reason_code']}', '{$d_1['batch_id']}', '{$d_1['deficit']}', '{$d_1['tipo']}', ";
            $s_ .= "'{$d_1['tipo_sub']}', '{$d_1['info_1']}', '{$d_1['info_2']}', '{$d_1['segmento']}', '{$d_1['proyecto']}', '{$d_1['idp']}', '{$header}')";
            $r_ = mysql_query($s_);
        }
    }
    $s_f = "select * from tmp_vertical where id_emp='{$_SESSION['IDEMP']}' group by no_parte, reason_code, dto_header order by no_folio asc ";
    $r_f = mysql_query($s_f);
    $i = 1;
    while ($d_f = mysql_fetch_array($r_f)) {
        $s_1 = "update tmp_vertical set grupo='{$i}' where no_parte='{$d_f['no_parte']}' and reason_code='{$d_f['reason_code']}' and dto_header='{$d_f['dto_header']}' ";
        $s_1 .= "and id_emp='{$_SESSION['IDEMP']}'";
        $r_1 = mysql_query($s_1);
        $i++;
    }
    $s_ = "select * from tmp_vertical where id_emp='{$_SESSION['IDEMP']}' group by grupo";
    $r_ = mysql_query($s_);
    $n_ = mysql_num_rows($r_);
    $ruta = "&fechai={$fechai}&fechaf={$fechaf}&reason={$reason}&buscar[0]={$buscar['0']}&filtros[0]={$filtros['0']}";
    $ruta .= "&buscar[1]={$buscar['1']}&filtros[1]={$filtros['1']}&buscar[2]={$buscar['2']}&filtros[2]={$filtros['2']}&stock={$stock}";
    ?>
	<form name="form_1" action="?op=ver" method="post">
    <table align="center">
    	<tr>
        	<td align="center" valign="middle">
            	<?php 
    if ($pag == '1') {
        ?>
                	<img src="../imagenes/ant_gris.png" title="Anterior" width="64">
                <?php 
    } else {
        ?>
                	<img src="../imagenes/ant.png" title="Anterior" width="64" onclick="antes('<?php 
        echo $pag;
        ?>
')" style="cursor:pointer;">
                <?php 
    }
    ?>
            </td>
            <td align="center">	
                <table align="center" class="tabla" cellpadding="-1" cellspacing="-1">
                <tbody>
                    <tr bgcolor="#FFFFFF" height="20">
                    	<td>
                            <table border="0" cellpadding="0" cellspacing="2">
                                 <tr height="20">
                                    <td align="center" background="../imagenes/v_material.png" width="95"></td>
                                 </tr>
                                 <tr height="20">
                                    <td align="center" background="../imagenes/v_planta.png" width="95"></td>
                                 </tr>
                                 <tr height="20">
                                    <td align="center" background="../imagenes/v_cantidad.png" width="95"></td>
                                 </tr>
                                 <tr height="20">
                                    <td align="center" background="../imagenes/v_sloc.png" width="95"></td>
                                 </tr>
                                 <tr height="20">
                                    <td align="center" background="../imagenes/v_batch.png" width="95"></td>
                                 </tr>
                                 <tr height="20">
                                    <td align="center" background="../imagenes/v_mov.png" width="95"></td>
                                 </tr>
                                 <tr height="20">
                                    <td align="center" background="../imagenes/v_num.png" width="95"></td>
                                 </tr>
                                 <tr height="20">
                                    <td align="center" background="../imagenes/v_blank.png" width="95"></td>
                                 </tr>
                                 <tr height="20">
                                    <td align="center" background="../imagenes/v_blank.png" width="95"></td>
                                 </tr>
                                 <tr height="20">
                                    <td align="center" background="../imagenes/v_header.png" width="95"></td>
                                 </tr>
                             </table>
                         </td>
                         <td>
                            <table border="0" cellpadding="0" cellspacing="2">
                                 <tr height="20">
                                    <?php 
    $r_1 = query("material", $pag);
    while ($d_1 = mysql_fetch_array($r_1)) {
        $parte = $d_1['no_parte'];
        ?>
                                    	<td align="left" background="../imagenes/v_fondo.png"><?php 
        echo $d_1['no_parte'];
        ?>
</td><?php 
    }
    ?>
                                 </tr>
                                 <tr height="20">
                                    <?php 
    $r_1 = query("planta", $pag);
    while ($d_1 = mysql_fetch_array($r_1)) {
        ?>
									<td align="left" background="../imagenes/v_fondo.png"><?php 
        echo $d_1['planta'];
        ?>
</td><?php 
    }
    ?>
                                 </tr>
                                 <tr height="20">
                                    <?php 
    $r_1 = query("cantidad", $pag);
    while ($d_1 = mysql_fetch_array($r_1)) {
        ?>
									<td align="left" background="../imagenes/v_fondo.png"><?php 
        echo intval($d_1['cantidad']);
        ?>
</td><?php 
    }
    ?>
                                 </tr>
                                 <tr height="20">
                                    <?php 
    $r_1 = query("apd", $pag);
    while ($d_1 = mysql_fetch_array($r_1)) {
        switch (strlen($d_1['apd'])) {
            case '1':
                $apd = "00" . $d_1['apd'];
                break;
            case '2':
                $apd = "0" . $d_1['apd'];
                break;
            case '3':
                $apd = $d_1['apd'];
                break;
        }
        ?>
                                     	<td align="left" background="../imagenes/v_fondo.png"><?php 
        echo $apd;
        ?>
</td><?php 
    }
    ?>
                                 </tr>
                                 <tr height="20">
                                    <?php 
    $r_1 = query("batch", $pag);
    while ($d_1 = mysql_fetch_array($r_1)) {
        ?>
									<td align="left" background="../imagenes/v_fondo.png"><?php 
        if ($d_1['batch_id'] != "NA") {
            echo $d_1['batch_id'];
        }
        ?>
</td><?php 
    }
    ?>
                                 </tr>
                                 <tr height="20">
                                    <?php 
    $r_1 = query("reason", $pag);
    while ($d_1 = mysql_fetch_array($r_1)) {
        ?>
									<td align="left" background="../imagenes/v_fondo.png"><?php 
        echo $d_1['reason_code'];
        ?>
</td><?php 
    }
    ?>
                                 </tr>
                                 <tr height="20">
                                    <?php 
    $r_1 = query("vacio", $pag);
    $j = 0;
    while ($d_1 = mysql_fetch_array($r_1)) {
        ?>
										<td align="left" background="../imagenes/v_fondo.png">
										<input type="text" name="sap" class="texto" size="15" onkeypress="return solo_numeros(event);" id="sap">
										</td><?php 
        $j++;
    }
    ?>
                                 </tr>
                                 <tr height="20">
                                    <?php 
    $r_1 = query("vacio", $pag);
    while ($d_1 = mysql_fetch_array($r_1)) {
        ?>
									<td align="left" background="../imagenes/v_fondo.png">&nbsp;</td><?php 
    }
    ?>
                                 </tr>
                                 <tr height="20">
                                    <?php 
    $r_1 = query("vacio", $pag);
    while ($d_1 = mysql_fetch_array($r_1)) {
        ?>
									<td align="left" background="../imagenes/v_fondo.png">&nbsp;</td><?php 
    }
    ?>
                                 </tr>
                                 <tr height="20">
                                    <?php 
    $r_1 = query("header", $pag);
    while ($d_1 = mysql_fetch_array($r_1)) {
        ?>
                                        <td align="left" background="../imagenes/v_fondo.png">
                                        <?php 
        echo $d_1['dto_header'];
        ?>
</td>
									<?php 
    }
    ?>
                                 </tr>
                             </table>
                         </td>
                    </tr>
                </tbody>
                </table>
           </td>
           <td align="center" valign="middle">
           	<?php 
    if ($pag == $n_) {
        ?>
           		<img src="../imagenes/sig_gris.png" title="Siguiente" width="64">
            <?php 
    } else {
        ?>
            	<img src="../imagenes/sig.png" title="Siguiente" width="64" onclick="sig('<?php 
        echo $pag;
        ?>
');" style="cursor:pointer;">
            <?php 
    }
    ?>
           </td>
    	</tr>
	</table>
    <br><div align="center">
    	<input type="button" class="submit" value="Regresar" onclick="regresar();">
    	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="button" class="submit" value="Guardar" onclick="guardar('<?php 
    echo $pag;
    ?>
');">
    </div>
    </form><br><br>
<?php 
}