Example #1
0
function listado($fechai, $fechaf, $proy_add, $proy_del, $aplica_oes, $buscar, $filtros, $reason, $pagina, $tipo, $editada, $motivo)
{
    if (!$aplica_oes) {
        $aplica_oes = 'no';
    }
    if ($tipo != 'proceso') {
        if (!$fechai) {
            $fechai = date("Y-m-d", mktime(0, 0, 0, date("m"), 1, date("Y")));
        }
        if (!$fechaf) {
            $fechaf = date("Y-m-d", mktime(0, 0, 0, date("m") + 1, 0, date("Y")));
        }
    }
    if (!$pagina) {
        $pagina = 1;
    }
    if ($proy_add != '') {
        $s_ = "insert into filtros values('','proyectos','{$proy_add}','{$_SESSION['IDEMP']}')";
        $r_ = mysql_query($s_);
    }
    if ($proy_del != '') {
        if ($proy_del == 'del_all') {
            $s_ = "delete from filtros where filtro='proyectos' and id_emp='{$_SESSION['IDEMP']}'";
            $r_ = mysql_query($s_);
        } else {
            $s_ = "delete from filtros where filtro='proyectos' and id_emp='{$_SESSION['IDEMP']}' and valor='{$proy_del}'";
            $r_ = mysql_query($s_);
        }
    }
    ?>
		
<div style="margin-left:100px;" class="titulo">
<table align="center" cellpadding="10" cellspacing="0" border="0">
<tr>
	<td class="titulo" width="190">
	<?php 
    if ($tipo == "proceso") {
        $titulo = "SCRAP EN PROCESO";
    }
    if ($tipo == "aprobados") {
        $titulo = "SCRAP APROBADO";
    }
    if ($tipo == "cancelados") {
        $titulo = "SCRAP CANCELADO";
    }
    if ($tipo == "rechazados") {
        $titulo = "SCRAP RECHAZADO";
    }
    echo $titulo;
    ?>
	
	</td>
	<td align="left">&nbsp;
	<span title="header=[&nbsp;&nbsp;<?php 
    echo $titulo;
    ?>
] body=[Usted puede revisar el estado de boleta de scrap en base a los colores y las banderas:<br><br>
	<table align='center' border='0' cellspacing='2'>
		<tr bgcolor='#FFFFFF'>
			<td><img src='../imagenes/flag_orange.gif'></td>
			<td width=200>&nbsp;Firmas que están pendientes</td>
		</tr><tr bgcolor='#FFFFFF'>
			<td><img src='../imagenes/flag_green.gif'></td>
			<td>&nbsp;Firmas aprobadas</td>
		</tr><tr bgcolor='#FFFFFF'>
			<td><img src='../imagenes/flag_red.gif'></td>
			<td>&nbsp;Firmas rechazadas</td>
		</tr></table><br>]"><img src="../imagenes/question.gif" width="20" height="20"></span>	
	</td>		
</tr>
</table></div><hr>
		
<div align="center" class="aviso">Utilice los filtros para generar búsquedas. Al cambiar un filtro, haga clic en el botón Buscar para refrescar la información. El reporte muestra toda la información sobre folios en proceso.</div>	
<form action="consultas.php" method="post" name="form1">
<input type="hidden" name="pagina" value="<?php 
    echo $pagina;
    ?>
" />
<input type="hidden" name="tipo" value="<?php 
    echo $tipo;
    ?>
" />
<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>
		<?php 
    if ($tipo == 'cancelados') {
        ?>
		<td align="center" bgcolor="#E6E6E6">Filtrar Motivos</td><?php 
    }
    ?>
    </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="center">
	<?php 
    $r_1 = mysql_query(get_proyectos_out($division));
    $n_1 = mysql_num_rows($r_1);
    ?>
	<select name="proy_add" class="texto" style="width:180px;" onchange="submit();">
		<option value="">Sin filtro (<?php 
    echo $n_1;
    ?>
)</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">
	<?php 
    $r_1 = mysql_query(get_proyectos_in());
    $n_1 = mysql_num_rows($r_1);
    ?>
	<select name="proy_del" class="texto" style="width:180px;" onchange="submit();">
	  	<option value="">En filtro (<?php 
    echo $n_1;
    ?>
)</option>	
		<option value="del_all" class="quitar">Quitar 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>
	<?php 
    if ($tipo == 'cancelados') {
        ?>
	<td align="center">
	<?php 
        $s_1 = "select * from motivos_cancel where activo='1' order by motivo";
        $r_1 = mysql_query($s_1);
        ?>
	<select name="motivo" class="texto" style="width:180px;">
	  	<option value=""></option>	
		<?php 
        while ($d_1 = mysql_fetch_array($r_1)) {
            ?>
		<option value="<?php 
            echo $d_1['motivo'];
            ?>
" <?php 
            if ($motivo == $d_1['motivo']) {
                ?>
 selected <?php 
            }
            ?>
><?php 
            echo $d_1['motivo'];
            ?>
</option><?php 
        }
        ?>
	</select></td><?php 
    }
    ?>
	
 </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 a_proceso='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 a_proceso='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 a_proceso='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="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;&nbsp;&nbsp;&nbsp;&nbsp;
	<input type="checkbox" name="reason" value="1" <?php 
    if ($reason == 1) {
        ?>
 checked="checked"<?php 
    }
    ?>
>
	Mostrar reason code
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<input type="checkbox" name="editada" value="1" <?php 
    if ($editada == 1) {
        ?>
 checked="checked"<?php 
    }
    ?>
>
	Mostrar sólo editadas
</div><br></form>

	<table align="center" border="0" class="texto">
	<tr>
		<td width="20" align="center"><img src="../imagenes/zoom.png" /></td>
    	<td width="60" align="left">Ver Boleta</td> 
        <td width="20" align="center">|</td>
		<td width="20" align="center"><img src="../imagenes/pencil.gif" /></td>
    	<td width="70" align="left">Editar Boleta</td> 
        <td width="20" align="center">|</td>
		<td width="20" align="center"><img src="../imagenes/tick.png" /></td>
    	<td width="40" align="left">Editada</td> 
        <td width="20" align="center">|</td>
		<td width="20" align="center"><img src="../imagenes/information.png" /></td>
    	<td width="40" align="left">Historial</td>      
        <td width="20" align="center">|</td>  
		<td width="20" align="center"><img src="../imagenes/attach.png" /></td>
    	<td width="50" align="left">Evidencias</td> 
        <td width="20" align="center">|</td>  
		<td width="20" align="center"><img src="../imagenes/ayuda.gif" /></td>
    	<td width="40" align="left">Detalles</td> 
        <td width="20" align="center">|</td>  
		<td width="20" align="center"><img src="../imagenes/flag_orange.gif" /></td>
    	<td width="50" align="left">Pendiente</td>  
        <td width="20" align="center">|</td>   
		<td width="20" align="center"><img src="../imagenes/flag_green.gif" /></td>
    	<td width="50" align="left">Aprobado</td>     
        <td width="20" align="center">|</td>   
		<td width="20" align="center"><img src="../imagenes/flag_red.gif" /></td>
    	<td width="50" align="left">Rechazado</td>                         
	</tr>
	</table><br>
    
<?php 
    $s_f = "select * from (select folios.*, sum(partes.cantidad) as cantidad_total, sum(partes.total) as costo_total, (select motivo from aut_bitacora where ";
    $s_f .= "aut_bitacora.no_folio=folios.no_folio and aut_bitacora.status='3' order by id desc limit 0,1) as motivo from scrap_partes as partes, scrap_folios as folios, ";
    $s_f .= "autorizaciones where folios.no_folio = partes.no_folio and autorizaciones.no_folio = folios.no_folio ";
    if ($_SESSION["DEPTO"] != 'esp') {
        $s_f .= " and autorizaciones.depto='{$_SESSION['DEPTO']}' ";
    } else {
        $s_f .= " and (autorizaciones.depto='esp_1' or autorizaciones.depto='esp_2') ";
    }
    switch ($tipo) {
        case "proceso":
            $s_f .= "and folios.activo='1' and folios.status='0' ";
            break;
        case "aprobados":
            $s_f .= "and folios.activo='1' and folios.status='1' ";
            break;
        case "cancelados":
            $s_f .= "and folios.activo='2' ";
            break;
        case "rechazados":
            $s_f .= "and folios.activo='1' and folios.status='2' ";
            break;
    }
    if ($editada == '1') {
        $s_f .= "and editada='1' ";
    }
    if ($aplica_oes == 'si') {
        $s_f .= " and autorizaciones.depto = 'oes' ";
    }
    if ($fechai != '' && $fechaf != '') {
        $s_f .= "and (fecha>='{$fechai}' and fecha<='{$fechaf}') ";
    }
    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) . " ) ";
        }
    }
    $s_f .= filtros_autorizador();
    $s_f .= " group by folios.no_folio order by folios.no_folio ASC) as general ";
    if ($motivo != '') {
        $s_f .= " where motivo like '{$motivo}' ";
    }
    $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']}";
    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="consultas.php?tipo=<?php 
            echo $tipo;
            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">
<tr bgcolor="#E6E6E6" height="20">
	<td align="center" width="30"><img src="../imagenes/zoom.png" /></td>
	<td align="center" width="30"><img src="../imagenes/information.png" /></td>
    <?php 
    if ($_SESSION["DEPTO"] == 'lo' || $_SESSION["DEPTO"] == 'loa') {
        $cols = 5;
        ?>
    <td align="center" width="25"><img src="../imagenes/attach.png" /></td><?php 
    } else {
        $cols = 4;
    }
    ?>
    
	<td align="center" width="30" rowspan="2"><img src="../imagenes/tick.png" /></td>
    <td align="center" width="50">Folio</td>
	<td align="center" width="40">Qty</td>
    <td align="center" width="100">Proyecto</td>
    <td align="center" width="100">Capturista</td>
	<?php 
    if ($reason != 1) {
        ?>
<td align="center" width="80">Cod.Scrap</td><?php 
    }
    ?>
	<?php 
    if ($reason == 1) {
        ?>
<td align="center" width="80">Reason Code</td><?php 
    }
    ?>
    <td align="center" width="80" colspan="2">Cod. Causa Original</td>
    <td align="center" width="100">Info.Obligatoria</td>
	<td align="center" width="70">Total</td>
	<td align="center" width="90">Fecha</td>
	<?php 
    if ($tipo == 'cancelados') {
        ?>
	<td align="center" width="150">Motivo</td><?php 
    }
    ?>
	<?php 
    if ($_SESSION["DEPTO"] == 'lo') {
        $class = 'naranja';
    } else {
        $class = '';
    }
    echo "<td width='60' align='center'><span class={$class}>LO</span></td>";
    if ($_SESSION["DEPTO"] == 'loa') {
        $class = 'naranja';
    } else {
        $class = '';
    }
    echo "<td width='60' align='center'><span class={$class}>LO-A</span></td>";
    if ($_SESSION["DEPTO"] == 'lpl') {
        $class = 'naranja';
    } else {
        $class = '';
    }
    echo "<td width='60' align='center'><span class={$class}>LPL</span></td>";
    if ($_SESSION["DEPTO"] == 'ffm') {
        $class = 'naranja';
    } else {
        $class = '';
    }
    echo "<td width='60' align='center'><span class={$class}>FFM</span></td>";
    if ($_SESSION["DEPTO"] == 'ffc') {
        $class = 'naranja';
    } else {
        $class = '';
    }
    echo "<td width='60' align='center'><span class={$class}>FFC</span></td>";
    if ($_SESSION["DEPTO"] == 'prod') {
        $class = 'naranja';
    } else {
        $class = '';
    }
    echo "<td width='60' align='center'><span class={$class}>Prod</span></td>";
    if ($_SESSION["DEPTO"] == 'sqm') {
        $class = 'naranja';
    } else {
        $class = '';
    }
    echo "<td width='60' align='center'><span class={$class}>SQM</span></td>";
    if ($_SESSION["DEPTO"] == 'fin') {
        $class = 'naranja';
    } else {
        $class = '';
    }
    echo "<td width='60' align='center'><span class={$class}>Finanzas</span></td>";
    if ($_SESSION["DEPTO"] == 'esp') {
        $class = 'naranja';
    } else {
        $class = '';
    }
    echo "<td width='60' align='center'><span class={$class}>ESP</span></td>";
    if ($_SESSION["DEPTO"] == 'oes') {
        $class = 'naranja';
    } else {
        $class = '';
    }
    echo "<td width='60' align='center'><span class={$class}>OES</span></td>";
    if ($_SESSION["DEPTO"] == 'inv') {
        $class = 'naranja';
    } else {
        $class = '';
    }
    echo "<td width='70' align='center'><span class={$class}>Inventarios</span></td>";
    ?>
</tr>
</thead>
<tbody>
<?php 
    $s_f .= " limit {$ini_},100";
    $r_1 = mysql_query($s_f);
    while ($d_1 = mysql_fetch_array($r_1)) {
        $qty = $qty + $d_1['cantidad_total'];
        $cost = $cost + $d_1['costo_total'];
        ?>
 
<tr onMouseOut="this.style.background='#F7F7F7'" onMouseOver="this.style.background='#FFDD99'" bgcolor="#F7F7F7" height="20">
	<td align="center">
		<a class="frame_ver_boleta" href="../detalles.php?op=ver_boleta&folio=<?php 
        echo $d_1['no_folio'];
        ?>
&buscar=no">
		<img src="../imagenes/zoom.png" border="0"></a></td>
	<td align="center">
		<a class="frame_ver_boleta" href="../detalles.php?op=historial&folio=<?php 
        echo $d_1['no_folio'];
        ?>
&buscar=no">
		<img src="../imagenes/information.png" border="0"></a></td>
	<?php 
        if ($_SESSION["DEPTO"] == 'lo' || $_SESSION["DEPTO"] == 'loa') {
            ?>
    <td align="center">    
	<?php 
            $s_c = "select * from configuracion where variable='ruta_evidencias'";
            $r_c = mysql_query($s_c);
            $d_c = mysql_fetch_array($r_c);
            $ruta = $d_c['valor'] . $d_1['archivo'];
            if ($d_1['archivo'] != '') {
                ?>
         	<a href="<?php 
                echo $ruta;
                ?>
" target="_blank">
         	<img src="../imagenes/attach.png" border="0"></a><?php 
            }
            ?>
    </td><?php 
        }
        ?>
        
    <td align="center">
    <?php 
        if ($d_1['editada'] == '1') {
            ?>
<img src="../imagenes/tick.png" border="0"><?php 
        } else {
            echo "&nbsp;";
        }
        ?>
</td>   
	<td align="center"><?php 
        echo $d_1['no_folio'];
        ?>
</td>
	<td align="center"><?php 
        echo $d_1['cantidad_total'];
        ?>
</td>
    <td align="left">&nbsp;&nbsp;<?php 
        echo $d_1['proyecto'];
        ?>
</td> 
    <td align="left">&nbsp;&nbsp;<?php 
        echo $d_1['empleado'];
        ?>
</td>
	<?php 
        if ($reason != 1) {
            ?>
<td align="center"><?php 
            echo $d_1['codigo_scrap'];
            ?>
</td><?php 
        }
        ?>
	<?php 
        if ($reason == 1) {
            ?>
<td align="center"><?php 
            echo $d_1['reason_code'];
            ?>
</td><?php 
        }
        ?>
	<td align="center" width="60">
    	<?php 
        $original = data_codigo_original($d_1['no_folio'], $d_1['financiero']);
        echo $original['codigo'];
        ?>
</td>
    <td align="center" width="20">
    	<?php 
        if ($d_1['financiero'] == '1') {
            ?>
 
		<span title='header=[&nbsp;&nbsp;Código de Causa Original] body=[<?php 
            echo detalles_codigo_original($d_1['no_folio']);
            ?>
]'>
		<img src="../imagenes/ayuda.gif" style="cursor: hand;"></span><?php 
        }
        ?>
   
    </td>     
    <td align="center"><?php 
        if ($d_1['info_1'] != 'NA') {
            echo $d_1['info_1'] . "-" . $d_1['info_2'];
        } else {
            echo "NA";
        }
        ?>
</td>   
	<td align="right"><?php 
        echo "\$ " . number_format($d_1['costo_total'], 2);
        ?>
&nbsp;&nbsp;</td>
	<td align="center"><?php 
        echo fecha_dmy($d_1['fecha']);
        ?>
</td>
	<?php 
        if ($tipo == 'cancelados') {
            ?>
	<td align="left">&nbsp;&nbsp;<?php 
            echo $d_1['motivo'];
            ?>
</td><?php 
        }
        ?>
	
	<td align="center"><?php 
        echo get_bandera("lo", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_bandera("loa", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_bandera("lpl", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_bandera("ffm", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_bandera("ffc", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_bandera("prod", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_bandera("sqm", $d_1['no_folio']);
        ?>
</td>
    <td align="center"><?php 
        echo get_bandera("fin", $d_1['no_folio']);
        ?>
</td>
    <td align="center"><?php 
        echo get_bandera("esp", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_bandera("oes", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_bandera("inv", $d_1['no_folio']);
        ?>
</td>
</tr>
<?php 
    }
    if ($qty > 0) {
        ?>
<tr onMouseOut="this.style.background='#E6E6E6'" onMouseOver="this.style.background='#FFDD99'" bgcolor="#E6E6E6" height="20">
	<td colspan="<?php 
        echo $cols;
        ?>
">&nbsp;</td>
	<td align="center" class="naranja"><b><?php 
        echo $qty;
        ?>
</b></td>
	<td colspan="5">&nbsp;</td>
	<td align="right" class="naranja"><b><?php 
        echo "\$ " . number_format($cost, 2);
        ?>
</b></td>
	<td colspan="13">&nbsp;</td>
</tr><?php 
    }
    ?>
</tbody>
</table><br><br><br>
<?php 
}
Example #2
0
function reporte($fechai, $fechaf, $buscar, $filtros)
{
    $s_ = "DROP VIEW vw_reportes_" . $_SESSION["IDEMP"];
    $r_ = mysql_query($s_);
    $s_1 = "CREATE OR REPLACE VIEW vw_reportes_" . $_SESSION["IDEMP"] . " AS ";
    $s_1 .= "select folios.no_folio, folios.fecha, sum(partes.cantidad) as cantidad_total, folios.planta, folios.division, folios.proyecto, folios.profit_center, ";
    $s_1 .= "folios.area, folios.codigo_scrap, folios.reason_code, sum(partes.total) as costo_total, folios.financiero, folios.archivo, folios.info_1, folios.info_2 ";
    $s_1 .= "from scrap_partes as partes, scrap_folios as folios where folios.status='2' and folios.no_folio = partes.no_folio and folios.activo='1' ";
    if ($fechai != '' && $fechaf != '') {
        $s_1 .= "and (fecha>='{$fechai}' and fecha<='{$fechaf}') ";
    }
    for ($i = 0; $i <= 2; $i++) {
        if ($buscar[$i] != '' && $filtros[$i] != '') {
            $s_1 .= " and ( ";
            $data = split(",", $buscar[$i]);
            for ($j = 0; $j < count($data); $j++) {
                $s_1 .= get_operador($filtros[$i], $data[$j]) . " or ";
            }
            $s_1 = substr($s_1, 0, -3) . " ) ";
        }
    }
    $s_1 .= filtros_autorizador($division);
    $s_1 .= " group by folios.no_folio order by folios.no_folio DESC";
    $r_1 = mysql_query($s_1);
}
Example #3
0
function listado($fechai, $fechaf, $proy_add, $proy_del, $aplica_oes, $buscar, $filtros, $pagina, $boton)
{
    if (!$aplica_oes) {
        $aplica_oes = 'no';
    }
    if (!$fechai) {
        $fechai = date("Y-m-d");
    }
    if (!$fechaf) {
        $fechaf = date("Y-m-d");
    }
    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 align="center" class="aviso">Si desea filtrar la información, utilice los calendarios y listas desplegables. Puede personalizar este reporte y conservar los cambios siempre que inicie sesión.</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 ver_filtros='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 ver_filtros='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 ver_filtros='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><br>
<table align="center" border="0" cellpadding="0" cellspacing="0">
<tr>
	<td width="150" align="center" valign="middle">
    	<input type="button" value="Buscar" class="submit" name="boton" onclick="search();" <?php 
    if ($boton == 1) {
        ?>
 disabled='disabled' <?php 
    }
    ?>
></td>
    <td width="150" align="center" valign="middle">
		<input type="button" value="Exportar" class="submit" onclick="exportar();"></td>
    <td width="150" align="center" valign="middle">   
	 <a class='personalizar' href='personalizar.php?op=personalizar&reporte=preliminar'>
     <img src="../imagenes/personalizar.png" border="0" width="120"></a></td>
</tr>
</table></form>

<?php 
    if (!$fechai) {
        $fechai = date("Y-m-d");
    }
    if (!$fechaf) {
        $fechaf = date("Y-m-d");
    }
    $s_f = "select folios.*, partes.no_parte, partes.descripcion, partes.cantidad, partes.total as costo_total, partes.ubicacion, ";
    $s_f .= "partes.docto_sap, partes.deficit, partes.tipo, partes.padre, partes.batch_id, partes.serial_unidad, partes.tipo_sub ";
    $s_f .= "from scrap_partes as partes, scrap_folios as folios, autorizaciones, numeros_parte ";
    $s_f .= "where folios.no_folio = partes.no_folio and autorizaciones.no_folio = folios.no_folio and partes.no_parte = numeros_parte.nombre ";
    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' ";
    }
    for ($i = 0; $i <= 2; $i++) {
        if ($filtros[$i] != '') {
            $por_folio = '1';
        }
    }
    if ($por_folio != '1') {
        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']}";
    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">
<tr bgcolor="#E6E6E6" height="20">
<td rowspan="2">&nbsp;</td>
<?php 
    $original = 0;
    $s_e = "select encabezados.nombre, reportes.campo from encabezados, reportes where reportes.id_emp='{$_SESSION['IDEMP']}' and ";
    $s_e .= "reportes.reporte = 'preliminar' and reportes.pantalla!='0' and reportes.campo=encabezados.campo ";
    $s_e .= "order by pantalla, nombre";
    $r_e = mysql_query($s_e);
    $i = 0;
    while ($d_e = mysql_fetch_array($r_e)) {
        if ($d_e['campo'] == 'cod_original') {
            $original = 1;
            ?>
    
        <td align="center" colspan="3"><?php 
            echo $d_e['nombre'];
            ?>
</td>
        <?php 
        } else {
            ?>
   
        <td align="center" rowspan="2"><?php 
            echo $d_e['nombre'];
            ?>
</td><?php 
        }
        ?>
	  <?php 
        $campos[$i] = $d_e['campo'];
        $i++;
    }
    ?>
	<td align="center" colspan="11">Autorización</td>
</tr>
<tr bgcolor="#E6E6E6" height="20">
    <?php 
    if ($original == '1') {
        ?>
  	<td align="center" width="150">Defecto</td>
	<td align="center" width="120">Tecnología</td>
	<td align="center" width="70">Código</td>  
    <?php 
    }
    ?>
	<td align="center" width="30">LO</td>
	<td align="center" width="30">LOA</td>
	<td align="center" width="30">LPL</td>
	<td align="center" width="30">FFM</td>
	<td align="center" width="30">FFC</td>
	<td align="center" width="30">Prod</td>
	<td align="center" width="30">SQM</td>
    <td align="center" width="30">Finanzas</td>
    <td align="center" width="30">ESP</td>
    <td align="center" width="30">OES</td>	
	<td align="center" width="30">Inv</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);
    while ($d_1 = mysql_fetch_array($r_1)) {
        if ($d_1['activo'] == '1') {
            $qty = 0 + $qty + $d_1['cantidad'];
            $cost = 0 + $cost + $d_1['costo_total'];
        }
        echo "<tr onMouseOut=\"{$mouse_out}\" onMouseOver=\"{$mouse_over}\" bgcolor=\"#F7F7F7\" height=\"20\">";
        ?>
	<td><a class="frame_ver_boleta" href="../detalles.php?op=historial&folio=<?php 
        echo $d_1['no_folio'];
        ?>
">
        	<img src="../imagenes/history.gif" border="0" alt="Historial"></a></td>              
	<?php 
        for ($i = 0; $i < count($campos); $i++) {
            switch ($campos[$i]) {
                case "costo_total":
                    echo "<td align='right' class='small'>\$ " . number_format($d_1['costo_total'], 2) . "&nbsp;</td>";
                    break;
                case "cod_original":
                    $original = data_codigo_original($d_1['no_folio'], $d_1['financiero']);
                    echo "<td align='left' class='small'>&nbsp;" . $original['defecto'] . "</td>";
                    echo "<td align='left' class='small'>&nbsp;" . $original['estacion'] . "</td>";
                    echo "<td align='left' class='small'>&nbsp;" . $original['codigo'] . "</td>";
                    break;
                case "docto_sap":
                    if ($d_1['deficit'] == '1') {
                        echo "<td align='left' class='small'>&nbsp;Déficit de Stock</td>";
                    } else {
                        if ($d_1['docto_sap'] != '0' && $d_1['docto_sap'] != '') {
                            echo "<td align='left' class='small'>&nbsp;" . $d_1['docto_sap'] . "</td>";
                        } else {
                            echo "<td align='left' class='small'>&nbsp;</td>";
                        }
                    }
                    break;
                case "info":
                    echo "<td align='left' class='small'>&nbsp;" . $d_1['info_1'] . $d_1['info_2'] . "</td>";
                    break;
                case "profit_center":
                    echo "<td align='left' class='small'>&nbsp;" . get_global_pc($d_1['no_parte']) . "</td>";
                    break;
                default:
                    echo "<td align='left' class='small'>&nbsp;" . $d_1[$campos[$i]] . "</td>";
                    break;
            }
        }
        ?>
	<td align="center" class="small"><?php 
        echo get_bandera("lo", $d_1['no_folio']);
        ?>
</td>
	<td align="center" class="small"><?php 
        echo get_bandera("loa", $d_1['no_folio']);
        ?>
</td>
	<td align="center" class="small"><?php 
        echo get_bandera("lpl", $d_1['no_folio']);
        ?>
</td>
	<td align="center" class="small"><?php 
        echo get_bandera("ffm", $d_1['no_folio']);
        ?>
</td>
	<td align="center" class="small"><?php 
        echo get_bandera("ffc", $d_1['no_folio']);
        ?>
</td>
	<td align="center" class="small"><?php 
        echo get_bandera("prod", $d_1['no_folio']);
        ?>
</td>
	<td align="center" class="small"><?php 
        echo get_bandera("sqm", $d_1['no_folio']);
        ?>
</td>
    <td align="center" class="small"><?php 
        echo get_bandera("fin", $d_1['no_folio']);
        ?>
</td>
    <td align="center" class="small"><?php 
        echo get_bandera("esp", $d_1['no_folio']);
        ?>
</td>
	<td align="center" class="small"><?php 
        echo get_bandera("oes", $d_1['no_folio']);
        ?>
</td>
	<td align="center" class="small"><?php 
        echo get_bandera("inv", $d_1['no_folio']);
        ?>
</td>
</tr>
<?php 
    }
    ?>
<tr bgcolor="#E6E6E6">
	<td>&nbsp;</td>
<?php 
    for ($i = 0; $i < count($campos); $i++) {
        if ($campos[$i] == 'costo_total') {
            echo "<td align='right' class='naranja'>\$ " . number_format($cost, 2) . "&nbsp;</td>";
        } elseif ($campos[$i] == 'cantidad') {
            echo "<td align='right' class='naranja'>{$qty}&nbsp;</td>";
        } else {
            echo "<td align='right' class='small'>&nbsp;</td>";
        }
    }
    ?>
	<td align="center" colspan="11">&nbsp;</td>	 		
</tr>
</tbody>
</table><br><br>
<?php 
    echo "<script>form1.boton.disabled=false;</script>";
}
Example #4
0
function autorizador($op, $fechai, $fechaf, $buscar, $filtros, $reason, $editados)
{
    ?>
<table align="center" class="tabla" border="0">
<thead>
	<tr bgcolor="#E6E6E6" height="20">
		<td colspan="28" align="center"><b>Reporte de SCRAP 
        <?php 
    switch ($op) {
        case "proceso":
            echo "en Proceso";
            break;
        case "rechazados":
            echo "Rechazado";
            break;
        case "aprobados":
            echo "Aprobado";
            break;
        case "cancelados":
            echo "Cancelado";
            break;
    }
    ?>
</b></td>
	</tr>
</thead>	
</table><br>

<table align="center" border="1">
<thead>
	<tr height="20">
	<td align="center" width="50" bgcolor="#FFCC33" rowspan="2"><b>No.Item</b></td>
	<td align="center" width="120" bgcolor="#FFCC33" rowspan="2"><b>Fecha</b></td>
	<td align="center" width="120" bgcolor="#FFCC33" rowspan="2"><b>No.Parte</b></td>
	<td align="center" width="150" bgcolor="#FFCC33" rowspan="2"><b>Descripción</b></td>
	<td align="center" width="150" bgcolor="#FFCC33" rowspan="2"><b>Qty</b></td>
	<td align="center" width="150" bgcolor="#FFCC33" rowspan="2"><b>Turno</b></td>
	<?php 
    if ($reason != 1) {
        ?>
<td align="center" width="120" bgcolor="#FFCC33" rowspan="2"><b>Código Scrap</b></td><?php 
    }
    ?>
	<?php 
    if ($reason == 1) {
        ?>
<td align="center" width="120" bgcolor="#FFCC33" rowspan="2"><b>Reason Code</b></td><?php 
    }
    ?>
	<td align="center" width="100" bgcolor="#FFCC33" rowspan="2"><b>Valor</b></td>
	<td align="center" width="100" bgcolor="#FFCC33" rowspan="2"><b>Proceso</b></td>
    <td align="center" width="100" bgcolor="#FFCC33" rowspan="2"><b>Proyecto</b></td>
	<td align="center" width="200" bgcolor="#FFCC33" rowspan="2"><b>Defecto</b></td>
    <td align="center" bgcolor="#FFCC33" colspan="6"><b>Cod.Causa Original</b></td>  
	<td align="center" width="120" bgcolor="#FFCC33" rowspan="2"><b>Posición</b></td>
	<td align="center" width="90" bgcolor="#FFCC33" rowspan="2"><b>Información Obligatoria</b></td>
	<td align="center" width="90" bgcolor="#FFCC33" rowspan="2"><b>Supervisor</b></td>
	<td align="center" colspan="8" bgcolor="#FFCC33"><b>Autorizaciones</b></td>
</tr>
<tr>
	<td align="center" width="180" bgcolor="#FFCC33"><b>Área</b></td>
	<td align="center" width="120" bgcolor="#FFCC33"><b>Estación</b></td>
	<td align="center" width="100" bgcolor="#FFCC33"><b>Línea</b></td>
	<td align="center" width="100" bgcolor="#FFCC33"><b>Defecto</b></td>
	<td align="center" width="100" bgcolor="#FFCC33"><b>Causa</b></td>
	<td align="center" width="90" bgcolor="#FFCC33"><b>Código Scrap</b></td>
	<td align="center" width="90" bgcolor="#FFCC33"><b>LO</b></td>
	<td align="center" width="90" bgcolor="#FFCC33"><b>LOA</b></td>
	<td align="center" width="90" bgcolor="#FFCC33"><b>LPL</b></td>
	<td align="center" width="90" bgcolor="#FFCC33"><b>FFM</b></td>
	<td align="center" width="90" bgcolor="#FFCC33"><b>FFC</b></td>
	<td align="center" width="90" bgcolor="#FFCC33"><b>PROD</b></td>
	<td align="center" width="90" bgcolor="#FFCC33"><b>SQM</b></td>
	<td align="center" width="90" bgcolor="#FFCC33"><b>INV</b></td>
</tr>
</thead>
<tbody>
<?php 
    if ($op == 'aprobados') {
        if (!$fechai) {
            $fechai = date("Y-m-d", mktime(0, 0, 0, date("m"), 1, date("Y")));
        }
        if (!$fechaf) {
            $fechaf = date("Y-m-d", mktime(0, 0, 0, date("m") + 1, 0, date("Y")));
        }
    }
    $s_1 = "select * from ";
    switch ($op) {
        case "proceso":
            $s_1 .= "vw_pendientes ";
            break;
        case "rechazados":
            $s_1 .= "vw_rechazados ";
            break;
        case "cancelados":
            $s_1 .= "vw_cancelados ";
            break;
        case "aprobados":
            $s_1 .= "vw_aprobados ";
            break;
    }
    $s_1 .= "where no_folio!='0' ";
    if ($fechai != '' && $fechaf != '') {
        $s_1 .= "and (fecha>='{$fechai}' and fecha<='{$fechaf}') ";
    }
    if ($editados == '1') {
        $s_1 .= "and editado='1' ";
    }
    for ($i = 0; $i <= 2; $i++) {
        if ($buscar[$i] != '' && $filtros[$i] != '') {
            $s_1 .= " and ( ";
            $data = split(",", $buscar[$i]);
            for ($j = 0; $j < count($data); $j++) {
                $s_1 .= get_operador($filtros[$i], $data[$j]) . " or ";
            }
            $s_1 = substr($s_1, 0, -3) . " ) ";
        }
    }
    $s_1 .= filtros_autorizador($division);
    $s_1 .= " order by no_folio desc";
    $r_1 = mysql_query($s_1);
    while ($d_1 = mysql_fetch_array($r_1)) {
        $qty = $qty + $d_1['cantidad'];
        $cost = $cost + $d_1['total'];
        ?>
<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['no_parte'];
        ?>
</td>
	<td align="left"><?php 
        echo $d_1['descripcion'];
        ?>
</td>
	<td align="center"><?php 
        echo $d_1['cantidad'];
        ?>
</td>
	<td align="center"><?php 
        echo $d_1['turno'];
        ?>
</td>
	<?php 
        if ($reason != 1) {
            ?>
<td align="center"><?php 
            echo $d_1['codigo_scrap'];
            ?>
</td><?php 
        }
        ?>
	<?php 
        if ($reason == 1) {
            ?>
<td align="center"><?php 
            echo $d_1['reason_code'];
            ?>
</td><?php 
        }
        ?>
 	<td align="right" class="small"><?php 
        echo number_format($d_1['total'], 2);
        ?>
</td>
	<td align="left"><?php 
        echo $d_1['estacion'];
        ?>
</td>
    <td align="left"><?php 
        echo $d_1['proyecto'];
        ?>
&nbsp;</td>
	<td align="left"><?php 
        echo $d_1['defecto'];
        ?>
</td>
    	<? $original = data_codigo_original($d_1['no_folio'],$d_1['financiero']); ?>
    <td align="left"><?php 
        echo $original['area'];
        ?>
&nbsp;</td>
    <td align="left"><?php 
        echo $original['estacion'];
        ?>
&nbsp;</td>
    <td align="left"><?php 
        echo $original['linea'];
        ?>
&nbsp;</td>
    <td align="left"><?php 
        echo $original['defecto'];
        ?>
&nbsp;</td>
    <td align="left"><?php 
        echo $original['causa'];
        ?>
&nbsp;</td>
    <td align="center"><?php 
        echo $original['codigo'];
        ?>
&nbsp;</td>  
	<td align="center"><?php 
        echo $d_1['ubicacion'];
        ?>
</td>
	<td align="center"><?php 
        echo $d_1['info_1'] . $d_1['info_2'];
        ?>
</td>
	<td align="left"><?php 
        echo $d_1['supervisor'];
        ?>
</td>
	<td align="center"><?php 
        echo get_datos("lo", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_datos("loa", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_datos("lpl", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_datos("ffm", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_datos("ffc", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_datos("prod", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_datos("sqm", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_datos("inv", $d_1['no_folio']);
        ?>
</td>	
</tr>
<?php 
    }
    ?>
<tr>
	<td align="right" colspan="4"><b>Totales&nbsp;&nbsp;</b></td>
	<td align="center" bgcolor="#FFCC33"><b><?php 
    echo $qty;
    ?>
</b></td>
	<td align="center" colspan="2">&nbsp;</td>
	<td align="center" bgcolor="#FFCC33"><b><?php 
    echo number_format($cost, 2);
    ?>
</b></td>
	<td align="center" colspan="20">&nbsp;</td>
</tr>
</tbody>
</table>
<?php 
}
Example #5
0
function listado($fechai, $fechaf, $proy_add, $proy_del, $buscar, $filtros, $reason, $editados, $pagina, $op)
{
    if (!$pagina) {
        $pagina = 1;
    }
    if ($op == 'aprobados') {
        if (!$fechai) {
            $fechai = date("Y-m-d", mktime(0, 0, 0, date("m"), 1, date("Y")));
        }
        if (!$fechaf) {
            $fechaf = date("Y-m-d", mktime(0, 0, 0, date("m") + 1, 0, date("Y")));
        }
    }
    ?>
	<table align="center" border="0" class="texto">
	<tr>
		<td width="20" align="center"><img src="../imagenes/zoom.png" /></td>
    	<td width="60" align="left">Ver Boleta</td> 
        <td width="20" align="center">|</td>
		<td width="20" align="center"><img src="../imagenes/pencil.gif" /></td>
    	<td width="70" align="left">Editar Boleta</td> 
        <td width="20" align="center">|</td>
		<td width="20" align="center"><img src="../imagenes/tick.png" /></td>
    	<td width="40" align="left">Editada</td> 
        <td width="20" align="center">|</td>
		<td width="20" align="center"><img src="../imagenes/information.png" /></td>
    	<td width="40" align="left">Historial</td>      
        <td width="20" align="center">|</td>  
		<td width="20" align="center"><img src="../imagenes/attach.png" /></td>
    	<td width="50" align="left">Evidencias</td> 
        <td width="20" align="center">|</td>  
		<td width="20" align="center"><img src="../imagenes/ayuda.gif" /></td>
    	<td width="40" align="left">Detalles</td> 
        <td width="20" align="center">|</td>  
		<td width="20" align="center"><img src="../imagenes/flag_orange.gif" /></td>
    	<td width="50" align="left">Pendiente</td>  
        <td width="20" align="center">|</td>   
		<td width="20" align="center"><img src="../imagenes/flag_green.gif" /></td>
    	<td width="50" align="left">Aprobado</td>     
        <td width="20" align="center">|</td>   
		<td width="20" align="center"><img src="../imagenes/flag_red.gif" /></td>
    	<td width="50" align="left">Rechazado</td>                         
	</tr>
	</table><br>
	<?php 
    $s_1 = "select no_folio, id_emp, fecha, sum(cantidad) as cantidad_total, planta, carga_masiva, proyecto, id_division, division, profit_center, area, codigo_scrap, ";
    $s_1 .= "reason_code, sum(total) as costo_total, financiero, archivo, info_1, info_2, editado from ";
    switch ($op) {
        case "proceso":
            $s_1 .= "vw_pendientes ";
            break;
        case "rechazados":
            $s_1 .= "vw_rechazados ";
            break;
        case "cancelados":
            $s_1 .= "vw_cancelados ";
            break;
        case "aprobados":
            $s_1 .= "vw_aprobados ";
            break;
    }
    $s_1 .= "where no_folio!='0' ";
    if ($fechai != '' && $fechaf != '') {
        $s_1 .= "and (fecha>='{$fechai}' and fecha<='{$fechaf}') ";
    }
    if ($editados == '1') {
        $s_1 .= "and editado='1' ";
    }
    for ($i = 0; $i <= 2; $i++) {
        if ($buscar[$i] != '' && $filtros[$i] != '') {
            $s_1 .= " and ( ";
            $data = split(",", $buscar[$i]);
            for ($j = 0; $j < count($data); $j++) {
                $s_1 .= get_operador($filtros[$i], $data[$j]) . " or ";
            }
            $s_1 = substr($s_1, 0, -3) . " ) ";
        }
    }
    $s_1 .= filtros_autorizador($division);
    $s_1 .= " group by no_folio";
    $r_1 = mysql_query($s_1);
    $total = mysql_num_rows($r_1);
    $pags = ceil($total / 100);
    $ini_ = ($pagina - 1) * 100;
    $i = 1;
    $j = 0;
    $ruta = "&op={$op}&fechai={$fechai}&fechaf={$fechaf}&reason={$reason}&tipo={$tipo}&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']}";
    if ($total > 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 $total;
        ?>
 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">
<tr bgcolor="#E6E6E6" height="20">
	<td align="center" width="40">&nbsp;</td>
	<td align="center" width="30"><img src="../imagenes/zoom.png" /></td>
	<td align="center" width="30"><img src="../imagenes/information.png" /></td>
    <?php 
    if ($_SESSION["DEPTO"] == 'lo' || $_SESSION["DEPTO"] == 'loa') {
        $cols = 6;
        ?>
    <td align="center" width="25"><img src="../imagenes/attach.png" /></td><?php 
    } else {
        $cols = 5;
    }
    ?>
    
	<td align="center" width="30" rowspan="2"><img src="../imagenes/tick.png" /></td>
    <td align="center" width="50">Folio</td>
	<td align="center" width="40">Qty</td>
    <td align="center" width="100">Proyecto</td>
	<?php 
    if ($reason != 1) {
        ?>
<td align="center" width="80">Cod.Scrap</td><?php 
    }
    ?>
	<?php 
    if ($reason == 1) {
        ?>
<td align="center" width="80">Reason Code</td><?php 
    }
    ?>
    <td align="center" width="80" colspan="2">Cod. Causa Original</td>
    <td align="center" width="100">Info.Obligatoria</td>
	<td align="center" width="70">Total</td>
	<td align="center" width="90">Fecha</td>
	<?php 
    if ($_SESSION["DEPTO"] == 'lo') {
        $class = 'naranja';
    } else {
        $class = '';
    }
    echo "<td width='60' align='center'><span class={$class}>LO</span></td>";
    if ($_SESSION["DEPTO"] == 'loa') {
        $class = 'naranja';
    } else {
        $class = '';
    }
    echo "<td width='60' align='center'><span class={$class}>LO-A</span></td>";
    if ($_SESSION["DEPTO"] == 'lpl') {
        $class = 'naranja';
    } else {
        $class = '';
    }
    echo "<td width='60' align='center'><span class={$class}>LPL</span></td>";
    if ($_SESSION["DEPTO"] == 'ffm') {
        $class = 'naranja';
    } else {
        $class = '';
    }
    echo "<td width='60' align='center'><span class={$class}>FFM</span></td>";
    if ($_SESSION["DEPTO"] == 'ffc') {
        $class = 'naranja';
    } else {
        $class = '';
    }
    echo "<td width='60' align='center'><span class={$class}>FFC</span></td>";
    if ($_SESSION["DEPTO"] == 'prod') {
        $class = 'naranja';
    } else {
        $class = '';
    }
    echo "<td width='60' align='center'><span class={$class}>Prod</span></td>";
    if ($_SESSION["DEPTO"] == 'sqm') {
        $class = 'naranja';
    } else {
        $class = '';
    }
    echo "<td width='60' align='center'><span class={$class}>SQM</span></td>";
    if ($_SESSION["DEPTO"] == 'inv') {
        $class = 'naranja';
    } else {
        $class = '';
    }
    echo "<td width='70' align='center'><span class={$class}>Inventarios</span></td>";
    ?>
</tr>
</thead>
<tbody>
<?php 
    if ($total > 0) {
        $s_1 .= " order by no_folio desc limit {$ini_},100";
        $r_1 = mysql_query($s_1);
        $i = $ini_ + 1;
        while ($d_1 = mysql_fetch_array($r_1)) {
            $qty = $qty + $d_1['cantidad_total'];
            $cost = $cost + $d_1['costo_total'];
            ?>
 
<tr onMouseOut="this.style.background='#F7F7F7'" onMouseOver="this.style.background='#FFDD99'" bgcolor="#F7F7F7" height="20">
	<td align="center"><?php 
            echo $i;
            ?>
</td>
	<td align="center">
		<a class="frame_ver_boleta" href="../detalles.php?op=ver_boleta&folio=<?php 
            echo $d_1['no_folio'];
            ?>
&buscar=no">
		<img src="../imagenes/zoom.png" border="0"></a></td>
	<td align="center">
		<a class="frame_ver_boleta" href="../detalles.php?op=historial&folio=<?php 
            echo $d_1['no_folio'];
            ?>
&buscar=no">
		<img src="../imagenes/information.png" border="0"></a></td>
	<?php 
            if ($_SESSION["DEPTO"] == 'lo' || $_SESSION["DEPTO"] == 'loa') {
                ?>
    <td align="center">    
	<?php 
                $s_c = "select * from configuracion where variable='ruta_evidencias'";
                $r_c = mysql_query($s_c);
                $d_c = mysql_fetch_array($r_c);
                $ruta = $d_c['valor'] . $d_1['archivo'];
                if ($d_1['archivo'] != '') {
                    ?>
         	<a href="<?php 
                    echo $ruta;
                    ?>
" target="_blank">
         	<img src="../imagenes/attach.png" border="0"></a><?php 
                }
                ?>
    </td><?php 
            }
            ?>
        
    <td align="center">
    <?php 
            if ($d_1['editado'] == '1') {
                ?>
<img src="../imagenes/tick.png" border="0"><?php 
            } else {
                echo "&nbsp;";
            }
            ?>
</td>   
	<td align="center"><?php 
            echo $d_1['no_folio'];
            ?>
</td>
	<td align="center"><?php 
            echo $d_1['cantidad_total'];
            ?>
</td>
    <td align="left">&nbsp;&nbsp;<?php 
            echo $d_1['proyecto'];
            ?>
</td> 
	<?php 
            if ($reason != 1) {
                ?>
<td align="center"><?php 
                echo $d_1['codigo_scrap'];
                ?>
</td><?php 
            }
            ?>
	<?php 
            if ($reason == 1) {
                ?>
<td align="center"><?php 
                echo $d_1['reason_code'];
                ?>
</td><?php 
            }
            ?>
	<td align="center" width="60">
    	<?php 
            $original = data_codigo_original($d_1['no_folio'], $d_1['financiero']);
            echo $original['codigo'];
            ?>
</td>
    <td align="center" width="20">
    	<?php 
            if ($d_1['financiero'] == '1') {
                ?>
 
		<span title='header=[&nbsp;&nbsp;Código de Causa Original] body=[<?php 
                echo detalles_codigo_original($d_1['no_folio']);
                ?>
]'>
		<img src="../imagenes/ayuda.gif" style="cursor: hand;"></span><?php 
            }
            ?>
   
    </td>     
    <td align="center"><?php 
            if ($d_1['info_1'] != 'NA') {
                echo $d_1['info_1'] . "-" . $d_1['info_2'];
            } else {
                echo "NA";
            }
            ?>
</td>   
	<td align="right"><?php 
            echo "\$ " . number_format($d_1['costo_total'], 2);
            ?>
&nbsp;&nbsp;</td>
	<td align="center"><?php 
            echo fecha_dmy($d_1['fecha']);
            ?>
</td>
	<td align="center"><?php 
            echo get_bandera("lo", $d_1['no_folio']);
            ?>
</td>
	<td align="center"><?php 
            echo get_bandera("loa", $d_1['no_folio']);
            ?>
</td>
	<td align="center"><?php 
            echo get_bandera("lpl", $d_1['no_folio']);
            ?>
</td>
	<td align="center"><?php 
            echo get_bandera("ffm", $d_1['no_folio']);
            ?>
</td>
	<td align="center"><?php 
            echo get_bandera("ffc", $d_1['no_folio']);
            ?>
</td>
	<td align="center"><?php 
            echo get_bandera("prod", $d_1['no_folio']);
            ?>
</td>
	<td align="center"><?php 
            echo get_bandera("sqm", $d_1['no_folio']);
            ?>
</td>
	<td align="center"><?php 
            echo get_bandera("inv", $d_1['no_folio']);
            ?>
</td>
</tr>
<?php 
            $i++;
        }
        if ($qty > 0) {
            ?>
<tr onMouseOut="this.style.background='#E6E6E6'" onMouseOver="this.style.background='#FFDD99'" bgcolor="#E6E6E6" height="20">
	<td colspan="<?php 
            echo $cols;
            ?>
">&nbsp;</td>
	<td align="center" class="naranja"><b><?php 
            echo $qty;
            ?>
</b></td>
	<td colspan="5">&nbsp;</td>
	<td align="right" class="naranja"><b><?php 
            echo "\$ " . number_format($cost, 2);
            ?>
</b></td>
	<td colspan="9">&nbsp;</td>
</tr><?php 
        }
    }
    ?>
</tbody>
</table><br><br><br>
<?php 
}
Example #6
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 
}
Example #7
0
function listado($fechai, $fechaf, $proy_add, $proy_del, $aplica_oes, $division, $tipo, $buscar, $filtros)
{
    if (!$aplica_oes) {
        $aplica_oes = 'no';
    }
    if (!$fechai) {
        $fechai = date("Y-m-d", mktime(0, 0, 0, date("m") - 1, date("d"), date("Y")));
    }
    if (!$fechaf) {
        $fechaf = date("Y-m-d", mktime(0, 0, 0, date("m") - 1, date("d"), date("Y")));
    }
    if ($proy_add != '') {
        $s_ = "insert into filtros values('','proyectos','{$proy_add}','{$_SESSION['IDEMP']}')";
        $r_ = mysql_query($s_);
    }
    if ($proy_del != '') {
        if ($proy_del == 'del_all') {
            $s_ = "delete from filtros where filtro='proyectos' and id_emp='{$_SESSION['IDEMP']}'";
            $r_ = mysql_query($s_);
        } else {
            $s_ = "delete from filtros where filtro='proyectos' and id_emp='{$_SESSION['IDEMP']}' and valor='{$proy_del}'";
            $r_ = mysql_query($s_);
        }
    }
    ?>
    
<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>
        <td align="center" width="100" bgcolor="#E6E6E6">División</td>
        <td align="center" width="100" bgcolor="#E6E6E6">Tipo Reporte</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="center">
	<?php 
    $r_1 = mysql_query(get_proyectos_out());
    $n_1 = mysql_num_rows($r_1);
    ?>
	<select name="proy_add" class="texto" style="width:180px;" onchange="submit();">
		<option value="">Sin filtro (<?php 
    echo $n_1;
    ?>
)</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">
	<?php 
    $r_1 = mysql_query(get_proyectos_in());
    $n_1 = mysql_num_rows($r_1);
    ?>
	<select name="proy_del" class="texto" style="width:180px;" onchange="submit();">
	  	<option value="">En filtro (<?php 
    echo $n_1;
    ?>
)</option>
        <option value="del_all" class="quitar">Quitar 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>
	<td align="center">
	<?php 
    $s_1 = "select divisiones.id, divisiones.nombre from divisiones, proyectos where divisiones.activo!='2' and divisiones.id = proyectos.id_division ";
    $s_2 = "select id_division from autorizadores where id_emp='{$_SESSION['IDEMP']}'";
    $r_2 = mysql_query($s_2);
    $i = 0;
    if (mysql_num_rows($r_2) > 0) {
        $s_1 .= "and (";
        while ($d_2 = mysql_fetch_array($r_2)) {
            if ($d_2['id_division'] != '0' && $d_2['id_division'] != '%') {
                $s_1 .= "id_division='{$d_2['id_division']}' or ";
                $divisiones[$i] = $d_2['id_division'];
                $i++;
            }
        }
        $s_1 = substr($s_1, 0, -4) . ")";
    }
    $s_1 .= "group by divisiones.id order by nombre";
    $r_1 = mysql_query($s_1);
    ?>
	<select name="division" class="texto" style="width:120px;">
	  	<option value="%">Todas</option>
		<?php 
    while ($d_1 = mysql_fetch_array($r_1)) {
        ?>
		<option value="<?php 
        echo $d_1['id'];
        ?>
" <?php 
        if ($division == $d_1['id']) {
            ?>
 selected="selected" <?php 
        }
        ?>
>
		<?php 
        echo $d_1['nombre'];
        ?>
</option><?php 
    }
    ?>
	</select></td>
	<td align="center">
	  <select name="tipo" class="texto" style="width:100px;">
		<option value="%" <?php 
    if ($tipo == "%") {
        ?>
 selected="selected" <?php 
    }
    ?>
>Todos</option>
        <option value="1" <?php 
    if ($tipo == "1") {
        ?>
 selected="selected" <?php 
    }
    ?>
>MB1A con OI</option>
        <option value="2" <?php 
    if ($tipo == "2") {
        ?>
 selected="selected" <?php 
    }
    ?>
>MB1A sin OI</option>
        <option value="3" <?php 
    if ($tipo == "3") {
        ?>
 selected="selected" <?php 
    }
    ?>
>ZSCR</option>        
	</select></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 definitivo='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 definitivo='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 definitivo='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="button" value="Buscar" class="submit" onclick="validar('reporte');">
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<input type="button" value="Exportar" class="submit" onclick="validar('excel');">
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<input type="button" value="Enviar Datos a SAP" class="submit" onclick="guardar();">
</div><br></form>

<?php 
    if ($fechai != '' && $fechaf != '' && $tipo != '' && $division != '') {
        $s_f = "select folios.*, partes.no_parte, partes.descripcion, partes.cantidad, partes.total as costo_total, partes.ubicacion, ";
        $s_f .= "partes.docto_sap, partes.deficit, partes.tipo, partes.padre, partes.batch_id, partes.serial_unidad, partes.tipo_sub ";
        $s_f .= "from scrap_partes as partes, scrap_folios as folios, autorizaciones, numeros_parte where folios.no_folio = partes.no_folio ";
        $s_f .= "and autorizaciones.no_folio = folios.no_folio and folios.activo='1' and folios.status='1' and partes.docto_sap!='0' and partes.docto_sap!='' ";
        $s_f .= "and partes.no_parte = numeros_parte.nombre  ";
        if ($division == '%') {
            if (count($divisiones) > 0) {
                $s_f .= " and (";
                for ($i = 0; $i < count($divisiones); $i++) {
                    $s_f .= " id_division='{$divisiones[$i]}' or ";
                }
                $s_f = substr($s_f, 0, -4) . ") ";
            }
        } else {
            $s_f .= " and id_division='{$division}' ";
        }
        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();
        }
        $r_1 = mysql_query($s_f);
        $tot = mysql_num_rows($r_1);
        ?>
    
<table align="center" class="tabla" border="0">
<thead>
	<tr bgcolor="#E6E6E6" height="20">
		<td colspan="6" align="center"><b>Autorizaciones de SCRAP</b></td>
	</tr>
	<tr bgcolor="#E6E6E6" height="20">
		<td align="center" width="150">LPL</td>
		<td align="center" width="150">Manufactura</td>
		<td align="center" width="150">FFC</td>
		<td align="center" width="150">LO</td>
		<td align="center" width="150">LO Almacén</td>
		<td align="center" width="150">Inventarios</td>
	</tr>
</thead>	
<tbody>
	<tr bgcolor="#F7F7F7" height="20">
		<td align="center"><?php 
        $s_2 = "select autorizaciones.empleado from autorizaciones, (" . $s_f . ") as general where autorizaciones.no_folio = general.no_folio and ";
        $s_2 .= "autorizaciones.depto='lpl' and autorizaciones.status='1' group by empleado order by empleado";
        $r_2 = mysql_query($s_2);
        while ($d_2 = mysql_fetch_array($r_2)) {
            echo $d_2['empleado'] . "<br>";
        }
        ?>
</td>
		<td align="center"><?php 
        $s_2 = "select autorizaciones.empleado from autorizaciones, (" . $s_f . ") as general where autorizaciones.no_folio = general.no_folio and ";
        $s_2 .= "autorizaciones.depto='prod' and autorizaciones.status='1' group by empleado order by empleado";
        $r_2 = mysql_query($s_2);
        while ($d_2 = mysql_fetch_array($r_2)) {
            echo $d_2['empleado'] . "<br>";
        }
        ?>
</td>
		<td align="center"><?php 
        $s_2 = "select autorizaciones.empleado from autorizaciones, (" . $s_f . ") as general where autorizaciones.no_folio = general.no_folio and ";
        $s_2 .= "autorizaciones.depto='ffc' and autorizaciones.status='1' group by empleado order by empleado";
        $r_2 = mysql_query($s_2);
        while ($d_2 = mysql_fetch_array($r_2)) {
            echo $d_2['empleado'] . "<br>";
        }
        ?>
</td>
		<td align="center"><?php 
        $s_2 = "select autorizaciones.empleado from autorizaciones, (" . $s_f . ") as general where autorizaciones.no_folio = general.no_folio and ";
        $s_2 .= "autorizaciones.depto='lo' and autorizaciones.status='1' group by empleado order by empleado";
        $r_2 = mysql_query($s_2);
        while ($d_2 = mysql_fetch_array($r_2)) {
            echo $d_2['empleado'] . "<br>";
        }
        ?>
</td>
		<td align="center"><?php 
        $s_2 = "select autorizaciones.empleado from autorizaciones, (" . $s_f . ") as general where autorizaciones.no_folio = general.no_folio and ";
        $s_2 .= "autorizaciones.depto='loa' and autorizaciones.status='1' group by empleado order by empleado";
        $r_2 = mysql_query($s_2);
        while ($d_2 = mysql_fetch_array($r_2)) {
            echo $d_2['empleado'] . "<br>";
        }
        ?>
</td>
		<td align="center"><?php 
        $s_2 = "select autorizaciones.empleado from autorizaciones, (" . $s_f . ") as general where autorizaciones.no_folio = general.no_folio and ";
        $s_2 .= "autorizaciones.depto='inv' and autorizaciones.status='1' group by empleado order by empleado";
        $r_2 = mysql_query($s_2);
        while ($d_2 = mysql_fetch_array($r_2)) {
            echo $d_2['empleado'] . "<br>";
        }
        ?>
</td>
	</tr>
</tbody>	
</table><br>

<table align="center" class="tabla">
<thead>
<tr bgcolor="#E6E6E6" height="20">
	<td>&nbsp;</td>
	<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">Cod. Causa Original</td>        
	<td align="center">O.I.</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">No.Docto.SAP</td>
	<td align="center">Tipo Material</td>
	<td align="center">Tipo Sub</td>
	<td align="center">Valor</td>
</tr>
</thead>
<tbody>
<?php 
        if ($tipo == '1' || $tipo == '%') {
            //Sección 1 reporte de TXS SAP con MB1A con Orden Interna
            $s_1 = $s_f . " and txs_sap='MB1A' and orden_interna!='NA' group by partes.id order by mov_sap, codigo_scrap, orden_interna, padre";
            $r_1 = mysql_query($s_1);
            if (mysql_num_rows($r_1) > 0) {
                echo "<tr bgcolor=\"#FF9900\"><td colspan=\"19\"></td></tr>";
                while ($d_1 = mysql_fetch_array($r_1)) {
                    ?>
	<tr onMouseOut="this.style.background='#F7F7F7'" onMouseOver="this.style.background='#FFDD99'" bgcolor="#F7F7F7" height="20">
		<td><a class="frame_ver_boleta" href="../detalles.php?op=historial&folio=<?php 
                    echo $d_1['no_folio'];
                    ?>
">
        	<img src="../imagenes/history.gif" border="0" alt="Historial"></a></td>
		<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 
                    $original = data_codigo_original($d_1['no_folio'], $d_1['financiero']);
                    echo $original['codigo'];
                    ?>
</td>    	<td align="left"><?php 
                    echo $d_1['orden_interna'];
                    ?>
</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="center"><?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="left"><?php 
                    if ($d_1['docto_sap'] != '0' && $d_1['docto_sap'] != '') {
                        echo $d_1['docto_sap'];
                    } else {
                        echo "";
                    }
                    ?>
</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>
    </tr>	
	<?php 
                }
            }
        }
        if ($tipo == '2' || $tipo == '%') {
            //Sección 2 reporte de TXS SAP con MB1A sin Orden Interna
            $s_2 = $s_f . " and txs_sap='MB1A' and orden_interna='NA' group by partes.id order by mov_sap, codigo_scrap, orden_interna, padre";
            $r_1 = mysql_query($s_2);
            if (mysql_num_rows($r_1) > 0) {
                echo "<tr bgcolor=\"#FF9900\"><td colspan=\"19\"></td></tr>";
                while ($d_1 = mysql_fetch_array($r_1)) {
                    ?>
	<tr onMouseOut="this.style.background='#F7F7F7'" onMouseOver="this.style.background='#FFDD99'" bgcolor="#F7F7F7" height="20">
		<td><a class="frame_ver_boleta" href="../detalles.php?op=historial&folio=<?php 
                    echo $d_1['no_folio'];
                    ?>
">
        	<img src="../imagenes/history.gif" border="0" alt="Historial"></a></td>
		<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 
                    $original = data_codigo_original($d_1['no_folio'], $d_1['financiero']);
                    echo $original['codigo'];
                    ?>
</td>    	<td align="left"><?php 
                    echo $d_1['orden_interna'];
                    ?>
</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="center"><?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="left"><?php 
                    if ($d_1['docto_sap'] != '0' && $d_1['docto_sap'] != '') {
                        echo $d_1['docto_sap'];
                    } else {
                        echo "";
                    }
                    ?>
</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>
	</tr>	
	<?php 
                }
            }
        }
        if ($tipo == '3' || $tipo == '%') {
            //Sección 3 reporte de TXS SAP con ZSCR
            $s_3 = $s_f . " and txs_sap='ZSCR' and (orden_interna='NA' or orden_interna='0') group by partes.id order by mov_sap, codigo_scrap, orden_interna, padre";
            $r_1 = mysql_query($s_3);
            if (mysql_num_rows($r_1) > 0) {
                echo "<tr bgcolor=\"#FF9900\"><td colspan=\"19\"></td></tr>";
                while ($d_1 = mysql_fetch_array($r_1)) {
                    ?>
	<tr onMouseOut="this.style.background='#F7F7F7'" onMouseOver="this.style.background='#FFDD99'" bgcolor="#F7F7F7" height="20">
		<td><a class="frame_ver_boleta" href="../detalles.php?op=historial&folio=<?php 
                    echo $d_1['no_folio'];
                    ?>
">
        	<img src="../imagenes/history.gif" border="0" alt="Historial"></a></td>
		<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 
                    $original = data_codigo_original($d_1['no_folio'], $d_1['financiero']);
                    echo $original['codigo'];
                    ?>
</td>	
        <td align="left"><?php 
                    echo $d_1['orden_interna'];
                    ?>
</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="center"><?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="left"><?php 
                    if ($d_1['docto_sap'] != '0' && $d_1['docto_sap'] != '') {
                        echo $d_1['docto_sap'];
                    } else {
                        echo "";
                    }
                    ?>
</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>
	</tr>	
	<?php 
                }
            }
        }
        ?>
</tbody>
</table><br><br>
<?php 
    }
}
Example #8
0
function corto($fechai, $fechaf, $buscar, $filtros)
{
    ?>
    
<table align="center" class="tabla" border="0">
<thead>
	<tr bgcolor="#E6E6E6" height="20">
		<td colspan="8" align="center"><b>REPORTE PRELIMINAR CORTO DE SCRAP</b></td>
	</tr>
</thead>	
</table><br>

<table align="center" border="1">
<thead>
<tr height="20">
		<td align="center" width="90" bgcolor="#FFCC33" rowspan="2"><b>Folio</b></td>
		<td align="center" width="90" bgcolor="#FFCC33" rowspan="2"><b>No. Parte</b></td>
		<td align="center" width="90" bgcolor="#FFCC33" rowspan="2"><b>Qty</b></td>
		<td align="center" width="90" bgcolor="#FFCC33" rowspan="2"><b>Fecha creación</b></td>
		<td align="center" width="90" bgcolor="#FFCC33" rowspan="2"><b>Hora creación</b></td>
        <td align="center" bgcolor="#FFCC33" colspan="3"><b>Inventarios</b></td>
</tr>
<tr height="20">
	<td align="center" width="90" bgcolor="#FFCC33"><b>Status</b></td>
	<td align="center" width="90" bgcolor="#FFCC33"><b>Fecha</b></td>
	<td align="center" width="90" bgcolor="#FFCC33"><b>Hora</b></td>
</tr>
</thead>
<tbody>
<?php 
    $s_f = "select folios.*, partes.no_parte, partes.cantidad, partes.padre, aut_bitacora.fecha, aut_bitacora.hora from scrap_partes as partes, scrap_folios as folios, ";
    $s_f .= "autorizaciones, numeros_parte, aut_bitacora where folios.no_folio = partes.no_folio and autorizaciones.no_folio = folios.no_folio and ";
    $s_f .= "partes.no_parte = numeros_parte.nombre and aut_bitacora.no_folio = folios.no_folio and aut_bitacora.depto='inv' and aut_bitacora.status='1' ";
    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 (folios.fecha>='{$fechai}' and folios.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)) {
        if ($d_1['activo'] == '1') {
            $qty = $qty + $d_1['cantidad'];
        }
        ?>
	  	<tr>
            <td align="center"><?php 
        echo $d_1['no_folio'];
        ?>
</td>
            <td align="left" style="mso-number-format:'0';"><?php 
        echo $d_1['no_parte'];
        ?>
</td>
            <td align="center"><?php 
        echo $d_1['cantidad'];
        ?>
</td>
            <?php 
        $a_folio = substr($d_1['timer'], 0, 4);
        $m_folio = substr($d_1['timer'], 4, 2);
        $d_folio = substr($d_1['timer'], 6, 2);
        $h_folio = substr($d_1['timer'], 8, 2);
        $min_folio = substr($d_1['timer'], 10, 2);
        $seg_folio = substr($d_1['timer'], 12, 2);
        $fecha_folio = date("d-m-Y", mktime($h_folio, $min_folio, $seg_folio, $m_folio, $d_folio, $a_folio));
        $hora_folio = date("H:i:s", mktime($h_folio, $min_folio, $seg_folio, $m_folio, $d_folio, $a_folio));
        ?>
            <td align="center"><?php 
        echo $fecha_folio;
        ?>
</td>
            <td align="center"><?php 
        echo $hora_folio;
        ?>
</td> 
            <td align="center"><?php 
        echo get_datos("inv", $d_1['no_folio']);
        ?>
</td>	   
            <td align="center"><?php 
        echo $d_1['fecha'];
        ?>
</td>
            <td align="center"><?php 
        echo $d_1['hora'];
        ?>
</td> 
		</tr> <?php 
    }
    ?>
		<tr>	
			<td colspan="2">&nbsp;</td>
   			<td align='right' bgcolor='#FFCC33'><?php 
    echo "{$qty}&nbsp;";
    ?>
</td>
			<td align="center" colspan="5">&nbsp;</td>	
		</tr>
</tbody>
</table>
<?php 
}
Example #9
0
function listado($fechai, $fechaf, $proy_add, $proy_del, $aplica_oes, $buscar, $filtros, $pagina, $boton)
{
    $s_ = "delete from reporte_turnos where (emp='0' or emp='{$_SESSION['IDEMP']}')";
    $r_ = mysql_query($s_);
    if (!$aplica_oes) {
        $aplica_oes = 'no';
    }
    if (!$fechai) {
        $fechai = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y")));
    }
    if (!$fechaf) {
        $fechaf = date("Y-m-d");
    }
    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 align="center" class="aviso">Si desea filtrar la información, utilice los calendarios y listas desplegables. Puede personalizar este reporte y conservar los cambios siempre que inicie sesión.</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="turnos_add[]" multiple="multiple" class="texto" id="turnos_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="turnos_del[]" multiple="multiple" class="texto" id="turnos_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 ver_filtros='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 ver_filtros='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 ver_filtros='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><br>

<table align="center" border="0" cellpadding="0" cellspacing="0">
<tr>
	<td width="150" align="center" valign="middle">
    	<input type="button" value="Buscar" class="submit" name="boton" onclick="search();" <?php 
    if ($boton == 1) {
        ?>
 disabled='disabled' <?php 
    }
    ?>
></td>
    <td width="150" align="center" valign="middle">
		<input type="button" value="Exportar" class="submit" onclick="exportar();"></td>
</tr>
</table></form>

<?php 
    $fecha_i = str_replace("-", "", $fechai);
    $fecha_f = str_replace("-", "", $fechaf);
    // INSERTO VALORES DE ACUERDO A LAS FECHAS SELECCIONADAS (1 MES POR DEFAULT)
    $s_r = "select * from reporte_turnos where emp='{$_SESSION['IDEMP']}' order by folio asc ";
    $r_r = mysql_query($s_r);
    if (mysql_num_rows($r_r) <= 0) {
        /*$s_ = "select folios.* from ".date("Y")."_scrap_folios as folios, scrap_partes as partes, scrap_folios as folios, autorizaciones, numeros_parte where timer BETWEEN '$fecha_i%' and '$fecha_f%' ";
        		$r_ = mysql_query($s_);
        		while($d_ = mysql_fetch_array($r_)){
        			$anio_r = substr($d_['timer'],0,4);
        			$mes_r = substr($d_['timer'],4,2);
        			$dia_r = substr($d_['timer'],6,2);
        			$horas_r = substr($d_['timer'],8,2);
        			$min_r = substr($d_['timer'],10,2);
        			$seg_r = substr($d_['timer'],12,2);
        			$fecha_r = $anio_r."-".$mes_r."-".$dia_r;
        			$hora_r = $horas_r.":".$min_r.":".$seg_r;
        			$folio = $d_['no_folio'];
        			$s_1 = "select * from tmp_turnos where '$fecha_r' between fecha_1 and fecha_2";
        			$r_1 = mysql_query($s_1);
        			while($d_1 = mysql_fetch_array($r_1)){
        				if($hora_r>="07:00" && $hora_r<="18:59"){
        					$s_2 = "insert into reporte_turnos values ('','$_SESSION[IDEMP]','$folio','$fecha_r','$hora_r','$d_[id_emp]','$d_[empleado]','$d_[id_apd]','$d_[apd]', ";
        					$s_2.= "'$d_1[turno_1]')";	
        					$r_2 = mysql_query($s_2);
        				} else {
        					$s_2 = "insert into reporte_turnos values ('','$_SESSION[IDEMP]','$folio','$fecha_r','$hora_r','$d_[id_emp]','$d_[empleado]','$d_[id_apd]','$d_[apd]', ";	
        					$s_2.= "'$d_1[turno_2]')";	
        					$r_2 = mysql_query($s_2);
        				}
        			}
        		}*/
        $s_ = "select folios.* from scrap_folios as folios, scrap_partes as partes, autorizaciones, numeros_parte where timer BETWEEN '{$fecha_i}%' and '{$fecha_f}%' ";
        $s_ .= "and folios.no_folio = partes.no_folio and autorizaciones.no_folio = folios.no_folio and partes.no_parte = numeros_parte.nombre ";
        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_ .= "and (fecha>='{$fechai}' and fecha<='{$fechaf}') ";
        }
        if ($aplica_oes == 'si') {
            $s_ .= " and autorizaciones.depto = 'oes' ";
        }
        if ($_SESSION["TYPE"] != 'autorizador') {
            $s_ .= filtros_capturista();
        }
        if ($_SESSION["TYPE"] == 'autorizador') {
            $s_ .= filtros_autorizador();
        }
        $s_ .= "group by folios.id order by folios.no_folio asc";
        $r_ = mysql_query($s_);
        while ($d_ = mysql_fetch_array($r_)) {
            $anio_r = substr($d_['timer'], 0, 4);
            $mes_r = substr($d_['timer'], 4, 2);
            $dia_r = substr($d_['timer'], 6, 2);
            $horas_r = substr($d_['timer'], 8, 2);
            $min_r = substr($d_['timer'], 10, 2);
            $fecha_r = $anio_r . "-" . $mes_r . "-" . $dia_r;
            $hora_r = $horas_r . ":" . $min_r;
            $folio = $d_['no_folio'];
            $s_1 = "select * from tmp_turnos where '{$fecha_r}' between fecha_1 and fecha_2";
            $r_1 = mysql_query($s_1);
            while ($d_1 = mysql_fetch_array($r_1)) {
                if ($hora_r >= "07:00" && $hora_r <= "18:59") {
                    $s_2 = "insert into reporte_turnos values ('','{$_SESSION['IDEMP']}', '{$folio}','{$fecha_r}','{$hora_r}','{$d_['id_emp']}','{$d_['empleado']}','{$d_['id_apd']}', ";
                    $s_2 .= "'{$d_['apd']}','{$d_1['turno_1']}')";
                    $r_2 = mysql_query($s_2);
                } else {
                    $s_2 = "insert into reporte_turnos values ('','{$_SESSION['IDEMP']}','{$folio}','{$fecha_r}','{$hora_r}','{$d_['id_emp']}','{$d_['empleado']}','{$d_['id_apd']}','{$d_['apd']}', ";
                    $s_2 .= "'{$d_1['turno_2']}')";
                    $r_2 = mysql_query($s_2);
                }
            }
        }
    }
    $r_ = mysql_query($s_r);
    $tot = mysql_num_rows($r_);
    $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']}";
    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">
<tr bgcolor="#E6E6E6" height="20">
	<td rowspan="2">&nbsp;</td>
  	<td align="center" width="150">Folio</td>
	<td align="center" width="80">Fecha</td>
	<td align="center" width="80">Hora</td>  
	<td align="center" width="80">Turno</td>
	<td align="center" width="150">Empleado</td>
	<td align="center" width="100">APD</td>
</tr>
</thead>
<tbody>
<?php 
    $mouse_over = "this.style.background='#FFDD99'";
    $mouse_out = "this.style.background='#F7F7F7'";
    $s_r .= " limit {$ini_}, 100";
    $r_1 = mysql_query($s_r);
    while ($d_1 = mysql_fetch_array($r_1)) {
        echo "<tr onMouseOut=\"{$mouse_out}\" onMouseOver=\"{$mouse_over}\" bgcolor=\"#F7F7F7\" height=\"20\">";
        ?>
	<td><a class="frame_ver_boleta" href="../detalles.php?op=ver_boleta&folio=<?php 
        echo $d_1['folio'];
        ?>
">
        	<img src="../imagenes/zoom.png" border="0" alt="Ver Boleta"></a></td>              
	<td align="center" class="small"><?php 
        echo $d_1['folio'];
        ?>
</td>
	<td align="center" class="small"><?php 
        echo $d_1['fecha'];
        ?>
</td>
	<td align="center" class="small"><?php 
        echo $d_1['hora'];
        ?>
</td>
	<td align="center" class="small"><?php 
        echo $d_1['turno'];
        ?>
</td>
	<td align="left" class="small"><?php 
        echo $d_1['empleado'];
        ?>
</td>
	<td align="center" class="small"><?php 
        echo $d_1['apd'];
        ?>
</td>
</tr>
<?php 
    }
    ?>
<tr bgcolor="#E6E6E6">
	<td align="center" colspan="7">&nbsp;</td>	 		
</tr>
</tbody>
</table><br><br>
<?php 
    echo "<script>form1.boton.disabled=false;</script>";
}
Example #10
0
function corto($fechai, $fechaf, $proy_add, $proy_del, $buscar, $filtros, $pagina, $boton)
{
    if (!$fechai) {
        $fechai = date("Y-m-d");
    }
    if (!$fechaf) {
        $fechaf = date("Y-m-d");
    }
    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 align="center" class="aviso">Si desea filtrar la información, utilice los calendarios y listas desplegables. Puede personalizar este reporte y conservar los cambios siempre que inicie sesión.</div>
<form action="?op=corto" 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 ver_filtros='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> 
	</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 ver_filtros='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>
	</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 ver_filtros='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> 
	</tr>         
</table><br>
<table align="center" border="0" cellpadding="0" cellspacing="0">
<tr>
	<td width="150" align="center" valign="middle">
    	<input type="button" value="Buscar" class="submit" name="boton" onclick="search('corto');" <?php 
    if ($boton == 1) {
        ?>
 disabled='disabled' <?php 
    }
    ?>
></td>
    <td width="150" align="center" valign="middle">
		<input type="button" value="Exportar" class="submit" onclick="exportar('corto');"></td>
</tr>
</table></form>

<?php 
    if (!$fechai) {
        $fechai = date("Y-m-d");
    }
    if (!$fechaf) {
        $fechaf = date("Y-m-d");
    }
    $s_f = "select folios.*, partes.no_parte, partes.cantidad, partes.padre, aut_bitacora.fecha, aut_bitacora.hora from scrap_partes as partes, scrap_folios as folios, ";
    $s_f .= "autorizaciones, numeros_parte, aut_bitacora where folios.no_folio = partes.no_folio and autorizaciones.no_folio = folios.no_folio and ";
    $s_f .= "partes.no_parte = numeros_parte.nombre and aut_bitacora.no_folio = folios.no_folio and aut_bitacora.depto='inv' and aut_bitacora.status='1' ";
    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 (folios.fecha>='{$fechai}' and folios.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);
    $tot = mysql_num_rows($r_1);
    $pags = ceil($tot / 100);
    $ini_ = ($pagina - 1) * 100;
    $i = 1;
    $j = 0;
    $ruta = "&fechai={$fechai}&fechaf={$fechaf}&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']}";
    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">
<tr bgcolor="#E6E6E6" height="20">
<td rowspan="2">&nbsp;</td>
	<td align="center" rowspan="2">Folio</td>
    <td align="center" rowspan="2">No. Parte</td>
    <td align="center" rowspan="2">Qty</td>
    <td align="center" rowspan="2">Fecha creación</td>
    <td align="center" rowspan="2">Hora creación</td>
	<td align="center" colspan="3">Autorización</td>
</tr>
<tr bgcolor="#E6E6E6" height="20">	
	<td align="center" width="30">Inv</td>
    <td align="center" width="30">Fecha</td>
    <td align="center" width="30">Hora</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);
    while ($d_1 = mysql_fetch_array($r_1)) {
        if ($d_1['activo'] == '1') {
            $qty = 0 + $qty + $d_1['cantidad'];
        }
        echo "<tr onMouseOut=\"{$mouse_out}\" onMouseOver=\"{$mouse_over}\" bgcolor=\"#F7F7F7\" height=\"20\">";
        ?>
	<td><a class="frame_ver_boleta" href="../detalles.php?op=historial&folio=<?php 
        echo $d_1['no_folio'];
        ?>
">
        	<img src="../imagenes/history.gif" border="0" alt="Historial"></a></td>   
    <td align="center" class="small"><?php 
        echo $d_1['no_folio'];
        ?>
</td>   
    <td align="left" class="small"><?php 
        echo $d_1['no_parte'];
        ?>
</td>   
    <td align="center" class="small"><?php 
        echo $d_1['cantidad'];
        ?>
</td> 
    <?php 
        $a_folio = substr($d_1['timer'], 0, 4);
        $m_folio = substr($d_1['timer'], 4, 2);
        $d_folio = substr($d_1['timer'], 6, 2);
        $h_folio = substr($d_1['timer'], 8, 2);
        $min_folio = substr($d_1['timer'], 10, 2);
        $seg_folio = substr($d_1['timer'], 12, 2);
        $fecha_folio = date("d-m-Y", mktime($h_folio, $min_folio, $seg_folio, $m_folio, $d_folio, $a_folio));
        $hora_folio = date("H:i:s", mktime($h_folio, $min_folio, $seg_folio, $m_folio, $d_folio, $a_folio));
        ?>
    <td align="center" class="small"><?php 
        echo $fecha_folio;
        ?>
</td>   
    <td align="center" class="small"><?php 
        echo $hora_folio;
        ?>
</td>           
	<td align="center" class="small"><?php 
        echo get_bandera("inv", $d_1['no_folio']);
        ?>
</td>
    <?php 
        $s_i = "select fecha, hora from aut_bitacora where depto='inv' and status='1' and fecha!='0000-00-00' and no_folio='{$d_1['no_folio']}'";
        $r_i = mysql_query($s_i);
        $d_i = mysql_fetch_array($r_i);
        $fecha_inv = $d_i['fecha'];
        $hora_inv = $d_i['hora'];
        ?>
    <td align="center"><?php 
        echo $fecha_inv;
        ?>
</td>
    <td align="center"><?php 
        echo $hora_inv;
        ?>
</td>
</tr>
<?php 
    }
    ?>
<tr bgcolor="#E6E6E6">
		<td colspan="3">&nbsp;</td>
   		<td align='right' class='naranja'><?php 
    echo "{$qty}&nbsp;";
    ?>
</td>
		<td align="center" colspan="5">&nbsp;</td>	 		
	</tr>
</tbody>
</table><br><br>
<?php 
    echo "<script>form1.boton.disabled=false;</script>";
}
Example #11
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 
}
Example #12
0
function consultas($fechai, $fechaf, $aplica_oes, $buscar, $filtros, $tipo, $reason, $editada, $motivo)
{
    if ($tipo != 'proceso') {
        if (!$fechai) {
            $fechai = date("Y-m-d", mktime(0, 0, 0, date("m"), 1, date("Y")));
        }
        if (!$fechaf) {
            $fechaf = date("Y-m-d", mktime(0, 0, 0, date("m") + 1, 0, date("Y")));
        }
    }
    ?>

<table align="center" class="tabla" border="0">
<thead>
	<tr bgcolor="#E6E6E6" height="20">
		<td colspan="32" align="center"><b>Reporte de SCRAP 
        <?php 
    switch ($tipo) {
        case "proceso":
            echo "en Proceso";
            break;
        case "rechazados":
            echo "Rechazado";
            break;
        case "aprobados":
            echo "Aprobado";
            break;
        case "cancelados":
            echo "Cancelado";
            break;
    }
    ?>
</b></td>
	</tr>
</thead>	
</table><br>

<table align="center" border="1">
<thead>
	<tr height="20">
	<td align="center" width="50" bgcolor="#FFCC33" rowspan="2"><b>No.Item</b></td>
	<td align="center" width="120" bgcolor="#FFCC33" rowspan="2"><b>Fecha</b></td>
	<td align="center" width="120" bgcolor="#FFCC33" rowspan="2"><b>No.Parte</b></td>
	<td align="center" width="150" bgcolor="#FFCC33" rowspan="2"><b>Descripción</b></td>
	<td align="center" width="150" bgcolor="#FFCC33" rowspan="2"><b>Qty</b></td>
	<td align="center" width="150" bgcolor="#FFCC33" rowspan="2"><b>Turno</b></td>
	<?php 
    if ($reason != 1) {
        ?>
<td align="center" width="120" bgcolor="#FFCC33" rowspan="2"><b>Código Scrap</b></td><?php 
    }
    ?>
	<?php 
    if ($reason == 1) {
        ?>
<td align="center" width="120" bgcolor="#FFCC33" rowspan="2"><b>Reason Code</b></td><?php 
    }
    ?>
	<td align="center" width="100" bgcolor="#FFCC33" rowspan="2"><b>Valor</b></td>
	<td align="center" width="100" bgcolor="#FFCC33" rowspan="2"><b>Proceso</b></td>
    <td align="center" width="100" bgcolor="#FFCC33" rowspan="2"><b>Proyecto</b></td>
    <td align="center" width="100" bgcolor="#FFCC33" rowspan="2"><b>Capturista</b></td>
	<td align="center" width="200" bgcolor="#FFCC33" rowspan="2"><b>Defecto</b></td>
    <td align="center" bgcolor="#FFCC33" colspan="6"><b>Cod.Causa Original</b></td>  
	<td align="center" width="120" bgcolor="#FFCC33" rowspan="2"><b>Posición</b></td>
	<td align="center" width="90" bgcolor="#FFCC33" rowspan="2"><b>Información Obligatoria</b></td>
	<td align="center" width="90" bgcolor="#FFCC33" rowspan="2"><b>Supervisor</b></td>
	<?php 
    if ($tipo == 'cancelados') {
        ?>
	<td align="center" width="150" bgcolor="#FFCC33" rowspan="2"><b>Motivo</b></td><?php 
    }
    ?>
	<td align="center" colspan="11" bgcolor="#FFCC33"><b>Autorizaciones</b></td>
</tr>
<tr>
	<td align="center" width="180" bgcolor="#FFCC33"><b>Área</b></td>
	<td align="center" width="120" bgcolor="#FFCC33"><b>Estación</b></td>
	<td align="center" width="100" bgcolor="#FFCC33"><b>Línea</b></td>
	<td align="center" width="100" bgcolor="#FFCC33"><b>Defecto</b></td>
	<td align="center" width="100" bgcolor="#FFCC33"><b>Causa</b></td>
	<td align="center" width="90" bgcolor="#FFCC33"><b>Código Scrap</b></td>
	<td align="center" width="90" bgcolor="#FFCC33"><b>LO</b></td>
	<td align="center" width="90" bgcolor="#FFCC33"><b>LOA</b></td>
	<td align="center" width="90" bgcolor="#FFCC33"><b>LPL</b></td>
	<td align="center" width="90" bgcolor="#FFCC33"><b>FFM</b></td>
	<td align="center" width="90" bgcolor="#FFCC33"><b>FFC</b></td>
	<td align="center" width="90" bgcolor="#FFCC33"><b>PROD</b></td>
	<td align="center" width="90" bgcolor="#FFCC33"><b>SQM</b></td>
    <td align="center" width="90" bgcolor="#FFCC33"><b>Finanzas</b></td>
	<td align="center" width="90" bgcolor="#FFCC33"><b>ESP</b></td>
    <td align="center" width="90" bgcolor="#FFCC33"><b>OES</b></td>   
    <td align="center" width="90" bgcolor="#FFCC33"><b>INV</b></td>
</tr>
</thead>
<tbody>
<?php 
    $s_f = "select * from (select folios.*, partes.no_parte, partes.descripcion, partes.cantidad, partes.total as costo_total, (select motivo from aut_bitacora where ";
    $s_f .= "aut_bitacora.no_folio=folios.no_folio and aut_bitacora.status='3' order by id desc limit 0,1) as motivo, partes.ubicacion from scrap_partes as partes, ";
    $s_f .= "scrap_folios as folios, autorizaciones where folios.no_folio = partes.no_folio and autorizaciones.no_folio = folios.no_folio ";
    if ($_SESSION["DEPTO"] != 'esp') {
        $s_f .= " and autorizaciones.depto='{$_SESSION['DEPTO']}' ";
    } else {
        $s_f .= " and (autorizaciones.depto='esp_1' or autorizaciones.depto='esp_2') ";
    }
    if ($editada == '1') {
        $s_f .= "and editada='1' ";
    }
    if ($aplica_oes == 'si') {
        $s_1 .= " and autorizaciones.depto = 'oes' ";
    }
    if ($fechai != '' && $fechaf != '') {
        $s_f .= "and (fecha>='{$fechai}' and fecha<='{$fechaf}') ";
    }
    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) . " ) ";
        }
    }
    switch ($tipo) {
        case "proceso":
            $s_f .= " and folios.status='0' and folios.activo='1' ";
            break;
        case "rechazados":
            $s_f .= " and folios.status='2' and folios.activo='1' ";
            break;
        case "cancelados":
            $s_f .= " and folios.activo='2' ";
            break;
        case "aprobados":
            $s_f .= " and folios.status='1' and folios.activo='1' ";
            break;
    }
    $s_f .= filtros_autorizador();
    $s_f .= " group by folios.no_folio order by folios.no_folio ASC) as general ";
    if ($motivo != '') {
        $s_f .= " where motivo like '{$motivo}' ";
    }
    $r_1 = mysql_query($s_f);
    while ($d_1 = mysql_fetch_array($r_1)) {
        $qty = $qty + $d_1['cantidad'];
        $cost = $cost + $d_1['costo_total'];
        ?>
<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['no_parte'];
        ?>
</td>
	<td align="left"><?php 
        echo $d_1['descripcion'];
        ?>
</td>
	<td align="center"><?php 
        echo $d_1['cantidad'];
        ?>
</td>
	<td align="center"><?php 
        echo $d_1['turno'];
        ?>
</td>
	<?php 
        if ($reason != 1) {
            ?>
<td align="center"><?php 
            echo $d_1['codigo_scrap'];
            ?>
</td><?php 
        }
        ?>
	<?php 
        if ($reason == 1) {
            ?>
<td align="center"><?php 
            echo $d_1['reason_code'];
            ?>
</td><?php 
        }
        ?>
 	<td align="right" class="small"><?php 
        echo number_format($d_1['costo_total'], 2);
        ?>
</td>
	<td align="left"><?php 
        echo $d_1['estacion'];
        ?>
</td>
    <td align="left"><?php 
        echo $d_1['proyecto'];
        ?>
&nbsp;</td>
    <td align="left"><?php 
        echo $d_1['empleado'];
        ?>
&nbsp;</td>
	<td align="left"><?php 
        echo $d_1['defecto'];
        ?>
</td>
    	<?php 
        $data = data_codigo_original($d_1['no_folio'], $d_1['financiero']);
        ?>
    <td align="left"><?php 
        echo $data['area'];
        ?>
&nbsp;</td>
    <td align="left"><?php 
        echo $data['estacion'];
        ?>
&nbsp;</td>
    <td align="left"><?php 
        echo $data['linea'];
        ?>
&nbsp;</td>
    <td align="left"><?php 
        echo $data['defecto'];
        ?>
&nbsp;</td>
    <td align="left"><?php 
        echo $data['causa'];
        ?>
&nbsp;</td>
    <td align="center"><?php 
        echo $data['codigo'];
        ?>
&nbsp;</td>  
	<td align="center"><?php 
        echo $d_1['ubicacion'];
        ?>
</td>
	<td align="center"><?php 
        echo $d_1['info_1'] . $d_1['info_2'];
        ?>
</td>
	<td align="left"><?php 
        echo $d_1['supervisor'];
        ?>
</td>
	<?php 
        if ($tipo == 'cancelados') {
            ?>
	<td align="left">&nbsp;&nbsp;<?php 
            echo $d_1['motivo'];
            ?>
</td><?php 
        }
        ?>
	
	<td align="center"><?php 
        echo get_datos("lo", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_datos("loa", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_datos("lpl", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_datos("ffm", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_datos("ffc", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_datos("prod", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_datos("sqm", $d_1['no_folio']);
        ?>
</td>
    <td align="center"><?php 
        echo get_datos("fin", $d_1['no_folio']);
        ?>
</td>
    <td align="center"><?php 
        echo get_datos("esp", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_datos("oes", $d_1['no_folio']);
        ?>
</td>
	<td align="center"><?php 
        echo get_datos("inv", $d_1['no_folio']);
        ?>
</td>	
</tr>
<?php 
    }
    ?>
<tr>
	<td align="right" colspan="4"><b>Totales&nbsp;&nbsp;</b></td>
	<td align="center" bgcolor="#FFCC33"><b><?php 
    echo $qty;
    ?>
</b></td>
	<td align="center" colspan="2">&nbsp;</td>
	<td align="center" bgcolor="#FFCC33"><b><?php 
    echo number_format($cost, 2);
    ?>
</b></td>
	<td align="center" colspan="24">&nbsp;</td>
</tr>
</tbody>
</table>
<?php 
}
Example #13
0
function listado($fechai, $fechaf, $proy_add, $proy_del, $buscar, $filtros, $tipo, $reason, $pagina)
{
    if (!$tipo) {
        $tipo = 'todos';
    }
    if (!$pagina) {
        $pagina = 1;
    }
    if (count($proy_add) > 0) {
        for ($i = 0; $i < count($proy_add); $i++) {
            if ($proy_add[$i] != '' && $proy_add[$i] != '0') {
                $s_ = "insert into filtros values('','proyectos','{$proy_add[$i]}','{$_SESSION['IDEMP']}')";
                $r_ = mysql_query($s_);
            }
        }
    }
    if (count($proy_del) > 0) {
        for ($i = 0; $i < count($proy_del); $i++) {
            if ($proy_del[$i] != '' && $proy_del[$i] != '0') {
                $s_ = "delete from filtros where filtro='proyectos' and id_emp='{$_SESSION['IDEMP']}' and valor='{$proy_del[$i]}'";
                $r_ = mysql_query($s_);
            }
        }
    }
    ?>
    
<div align="center" class="aviso">Utilice los filtros para generar búsquedas. Al cambiar un filtro, haga clic en el botón Buscar para refrescar la información. El reporte muestra toda la información sobre folios pendientes de autorizar.</div>	
<form action="?op=listado" method="post" name="form1">
<input type="hidden" name="pagina" value="<?php 
    echo $pagina;
    ?>
" />
<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>
        <?php 
    if ($_SESSION["DEPTO"] == 'inv') {
        ?>
       		<td align="center" bgcolor="#E6E6E6">Tipo</td><?php 
    }
    ?>
    </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>
	<?php 
    if ($_SESSION["DEPTO"] == 'inv') {
        ?>
    <td align="center">
	<select name="tipo" class="texto" style="width:120px;">
	  	<option value="todos" <?php 
        if ($tipo == 'todos') {
            ?>
 selected="selected"<?php 
        }
        ?>
>Todos</option>	
        <option value="aprobados" <?php 
        if ($tipo == 'aprobados') {
            ?>
 selected="selected"<?php 
        }
        ?>
>Aprobados</option>
        <option value="cancelados" <?php 
        if ($tipo == 'cancelados') {
            ?>
 selected="selected"<?php 
        }
        ?>
>Cancelados</option>
        <option value="pendientes" <?php 
        if ($tipo == 'pendientes') {
            ?>
 selected="selected"<?php 
        }
        ?>
>Pendientes</option>
        <option value="rechazados" <?php 
        if ($tipo == 'rechazados') {
            ?>
 selected="selected"<?php 
        }
        ?>
>Rechazados</option>
	</select></td><?php 
    }
    ?>
	
</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 scrap_firmar='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> 
	</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 scrap_firmar='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> 
	</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 scrap_firmar='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> 
	</tr>         
</table>
<div align="center" class="texto"><br>
	<input type="button" value="Buscar" class="submit" onclick="validar('reporte');">
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<input type="button" value="Exportar" class="submit" onclick="validar('excel');">
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<input type="checkbox" name="reason" value="1" <?php 
    if ($reason == 1) {
        ?>
 checked="checked"<?php 
    }
    ?>
>
	Mostrar Reason code
</div><br>

<table align="center" border="0" class="texto">
<tr>
	<td width="20" align="center"><img src="../imagenes/zoom.png" /></td>
   	<td width="60" align="left">Ver Boleta</td> 
    <td width="20" align="center">|</td>
	<td width="20" align="center"><img src="../imagenes/information.png" /></td>
   	<td width="40" align="left">Historial</td>      
    <td width="20" align="center">|</td>  
	<td width="20" align="center"><img src="../imagenes/attach.png" /></td>
   	<td width="50" align="left">Evidencias</td> 
    <td width="20" align="center">|</td>  
	<td width="20" align="center"><img src="../imagenes/ayuda.gif" /></td>
   	<td width="40" align="left">Detalles</td> 
</tr>
</table><br>

<?php 
    //Reviso que realmente tenga asignada una división, profit_center, área o proyecto
    $s_p = "select * from autorizadores where id_emp='{$_SESSION['IDEMP']}'";
    $r_p = mysql_query($s_p);
    if (mysql_num_rows($r_p) > 0) {
        //CONSULTA GLOBAL
        $s_f = "select folios.*, sum(partes.cantidad) as cantidad_total, sum(partes.total) as costo_total from scrap_partes as partes, ";
        $s_f .= "scrap_folios as folios, autorizaciones, numeros_parte where folios.no_folio = partes.no_folio and autorizaciones.no_folio = ";
        $s_f .= "folios.no_folio and partes.no_parte = numeros_parte.nombre ";
        if ($_SESSION["DEPTO"] != 'esp') {
            $s_f .= " and autorizaciones.depto='{$_SESSION['DEPTO']}' ";
        } else {
            $s_f .= " and (autorizaciones.depto='esp_1' or autorizaciones.depto='esp_2') ";
        }
        switch ($tipo) {
            case "todos":
                if ($_SESSION["DEPTO"] == 'inv') {
                    $s_f .= " and (folios.status='0' or folios.status='2') and folios.activo='1' and ";
                    $s_f .= "autorizaciones.status='0' ";
                }
                if ($_SESSION["DEPTO"] != 'inv') {
                    $s_f .= " and folios.status='0' and folios.activo='1' and autorizaciones.status='0' ";
                }
                break;
            case "aprobados":
                $s_f .= " and not exists (select no_folio from autorizaciones where status!='1' and folios.no_folio=";
                $s_f .= "autorizaciones.no_folio and autorizaciones.depto!='inv') and ";
                $s_f .= "folios.status='0' and folios.activo='1' and autorizaciones.status='0' ";
                break;
            case "cancelados":
                $s_f .= " and (folios.status='0' or folios.status='2') and folios.activo='2' ";
            case "rechazados":
                $s_f .= " and folios.status='2' and folios.activo='1' ";
                break;
            case "pendientes":
                $s_f .= " and folios.status='0' and folios.activo='1' and autorizaciones.status='0' ";
                break;
        }
        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++) {
                    if ($filtros[$i] == "global_pc") {
                        $s_f .= get_operador($filtros[$i], $data[$j]) . " or ";
                    }
                    $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}') ";
        }
        $s_f .= filtros_autorizador();
        $s_f .= " group by no_folio order by no_folio DESC";
        $r_1 = mysql_query($s_f);
        $d_1 = mysql_fetch_array($r_1);
        $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}&tipo={$tipo}&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']}";
        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 
        }
        ?>
    
    
<?php 
        if ($_SESSION["DEPTO"] == 'inv') {
            //Mostrar la hora y detalles de la última autorización existente de cualquier perfil
            $s_b = "select aut_bitacora.*, general.* from aut_bitacora, autorizaciones, (" . $s_f . ") as general where general.no_folio = aut_bitacora.no_folio and ";
            $s_b .= "autorizaciones.no_folio = general.no_folio and general.status='0' and autorizaciones.status='0' and aut_bitacora.status='1' order by aut_bitacora.fecha ";
            $s_b .= "desc, aut_bitacora.hora desc";
            $r_b = mysql_query($s_b);
            $d_b = mysql_fetch_array($r_b);
            ?>
    
<table align="center" class="tabla">
<tr>
   <td align="center" bgcolor="#CCCCCC" width="100"><b>Folio</b></td>
   <td align="center" bgcolor="#CCCCCC" width="100"><b>Fecha</b></td>
   <td align="center" bgcolor="#CCCCCC" width="100"><b>Hora</b></td>
   <td align="center" bgcolor="#CCCCCC" width="100"><b>Perfil</b></td>
   <td align="center" bgcolor="#CCCCCC" width="250"><b>Empleado</b></td>
   <td align="center" bgcolor="#CCCCCC" width="120" rowspan="2"><input type="button" value="Descargar Reporte" class="submit" onclick="descargar();"></td>
</tr>   
<tr>
	<td align="center"><?php 
            echo $d_b['no_folio'];
            ?>
</td>
    <td align="center"><?php 
            echo $d_b['fecha'];
            ?>
</td>
    <td align="center"><?php 
            echo $d_b['hora'];
            ?>
</td>
    <td align="center"><?php 
            switch ($d_b["depto"]) {
                case "lo":
                    echo "LO";
                    break;
                case "loa":
                    echo "LO-Almacén";
                    break;
                case "lpl":
                    echo "LPL";
                    break;
                case "ffm":
                    echo "FFM";
                    break;
                case "ffc":
                    echo "FFC";
                    break;
                case "prod":
                    echo "Producción";
                    break;
                case "sqm":
                    echo "SQM";
                    break;
                case "fin":
                    echo "Finanzas";
                    break;
                case "esp":
                    echo "ESP";
                    break;
                case "oes":
                    echo "OES";
                    break;
            }
            ?>
</td>
	<td align="left">&nbsp;<?php 
            echo $d_b['empleado'];
            ?>
</td>        
</tr>
</table><br>
<?php 
        }
        ?>
  
   
<table align="center" class="tabla">
<thead>
<tr bgcolor="#E6E6E6" height="20">
	<td align="center" width="25">
    	<input type="checkbox" name="todos" id="todos" value="1" <?php 
        if ($todos == '1') {
            ?>
 checked="checked" <?php 
        }
        ?>
 onclick="select_all('<?php 
        echo $tot;
        ?>
');"></td>
	<td align="center" width="25"><img src="../imagenes/zoom.png" /></td>
	<td align="center" width="25"><img src="../imagenes/information.png" /></td>
    <?php 
        if ($_SESSION["DEPTO"] == 'lo' || $_SESSION["DEPTO"] == 'loa') {
            ?>
    <td align="center" width="25"><img src="../imagenes/attach.png" /></td><?php 
        }
        ?>
	<td align="center" width="60">Folio</td>
	<td align="center" width="90">Fecha</td>
    <?php 
        if ($reason != 1) {
            ?>
<td align="center" width="90">Cod.Scrap</td><?php 
        }
        ?>
    <?php 
        if ($reason == 1) {
            ?>
<td align="center" width="90">Reason Code</td><?php 
        }
        ?>
	<td align="center" width="90" colspan="2">Cod. Causa Original</td>    
	<td align="center" width="100">Info.Obligatoria</td>
    <td align="center" width="60">Qty</td>
	<td align="center" width="80">Total</td>	
	<td align="center" width="250">Números de Parte</td>
    <td align="center" width="50">APD</td>
    <td align="center" width="100">Proyecto</td>
    <td align="center" width="100">Capturista</td>
	<?php 
        switch ($_SESSION["DEPTO"]) {
            case "lo":
                echo "<td align='center' colspan=2>LO</td>";
                break;
            case "loa":
                echo "<td align='center' colspan=2>LO-Almacén</td>";
                break;
            case "lpl":
                echo "<td align='center' colspan=2>LPL</td>";
                break;
            case "ffm":
                echo "<td align='center' colspan=2>FFM</td>";
                break;
            case "ffc":
                echo "<td align='center' colspan=2>FFC</td>";
                break;
            case "prod":
                echo "<td align='center' colspan=2>Producción</td>";
                break;
            case "sqm":
                echo "<td align='center' colspan=2>SQM</td>";
                break;
            case "fin":
                echo "<td align='center' colspan=2>Finanzas</td>";
                break;
            case "esp":
                echo "<td align='center' colspan=2>ESP</td>";
                break;
            case "oes":
                echo "<td align='center' colspan=2>OES</td>";
                break;
            case "inv":
                echo "<td width='30' align='center'>LO</td>";
                echo "<td width='30' align='center'>LO-A</td>";
                echo "<td width='30' align='center'>LPL</td>";
                echo "<td width='30' align='center'>FFM</td>";
                echo "<td width='30' align='center'>FFC</td>";
                echo "<td width='30' align='center'>Prod</td>";
                echo "<td width='30' align='center'>SQM</td>";
                echo "<td width='30' align='center'>Finanzas</td>";
                echo "<td width='30' align='center'>ESP</td>";
                echo "<td width='30' align='center'>OES</td>";
                echo "<td width='30' align='center'>Inv</td>";
                echo "<td align='center' colspan='3'>Acciones</td>";
                break;
        }
        ?>
</tr>
</thead>
<tbody>
<?php 
        $qty = $cost = 0;
        $s_f .= " limit {$ini_}, 100";
        $r_1 = mysql_query($s_f);
        $n_1 = mysql_num_rows($r_1);
        while ($d_1 = mysql_fetch_array($r_1)) {
            $qty = $qty + $d_1['cantidad_total'];
            $cost = $cost + $d_1['costo_total'];
            $dis = firma_inventarios($d_1['no_folio']);
            ?>
<tr onMouseOut="this.style.background='#F7F7F7'" onMouseOver="this.style.background='#FFDD99'" bgcolor="#F7F7F7" height="20">
	<td align="center">
    	<input type="checkbox" name="varios[]" id="varios" value="<?php 
            echo $d_1['no_folio'];
            ?>
" <?php 
            echo firma_inventarios($d_1['no_folio']);
            ?>
></td>	
	<td align="center">
		<a class="frame_ver_boleta" href="../detalles.php?op=ver_boleta&folio=<?php 
            echo $d_1['no_folio'];
            ?>
&buscar=no">
		<img src="../imagenes/zoom.png" border="0"></a></td>
	<td align="center">
		<a class="frame_ver_boleta" href="../detalles.php?op=historial&folio=<?php 
            echo $d_1['no_folio'];
            ?>
&buscar=no">
		<img src="../imagenes/information.png" border="0"></a></td>		
	<?php 
            if ($_SESSION["DEPTO"] == 'lo' || $_SESSION["DEPTO"] == 'loa') {
                $cols = 10;
                ?>
    <td align="center">    
	<?php 
                $s_c = "select * from configuracion where variable='ruta_evidencias'";
                $r_c = mysql_query($s_c);
                $d_c = mysql_fetch_array($r_c);
                $ruta = $d_c['valor'] . $d_1['archivo'];
                if ($d_1['archivo'] != '') {
                    ?>
         	<a href="<?php 
                    echo $ruta;
                    ?>
" target="_blank">
         	<img src="../imagenes/attach.png" border="0"></a><?php 
                }
                ?>
    </td><?php 
            } else {
                $cols = 9;
            }
            ?>
	<td align="center"><?php 
            echo $d_1['no_folio'];
            ?>
</td>
	<td align="center"><?php 
            echo fecha_dmy($d_1['fecha']);
            ?>
</td>
	<?php 
            if ($reason != 1) {
                ?>
<td align="center"><?php 
                echo $d_1['codigo_scrap'];
                ?>
</td><?php 
            }
            ?>
	<?php 
            if ($reason == 1) {
                ?>
<td align="center"><?php 
                echo $d_1['reason_code'];
                ?>
</td><?php 
            }
            ?>
	<td align="center" width="70">
		<?php 
            $original = data_codigo_original($d_1['no_folio'], $d_1['financiero']);
            echo $original['codigo'];
            ?>
</td>
    <td align="center" width="20">
    	<?php 
            if ($d_1['financiero'] == '1') {
                ?>
 
		<span title='header=[&nbsp;&nbsp;Código de Causa Original] body=[<?php 
                echo detalles_codigo_original($d_1['no_folio']);
                ?>
]'>
		<img src="../imagenes/ayuda.gif" style="cursor: hand;"></span><?php 
            }
            ?>
   
    </td>  
    <td align="center"><?php 
            if ($d_1['info_1'] != 'NA' && $d_1['info_1'] != '') {
                echo $d_1['info_1'] . "-" . $d_1['info_2'];
            } else {
                echo "NA";
            }
            ?>
</td>      
	<td align="center"><?php 
            echo $d_1['cantidad_total'];
            ?>
</td>
	<td align="right"><?php 
            echo "\$ " . number_format($d_1['costo_total'], 2);
            ?>
&nbsp;</td>
	<td align="center">
	<?php 
            if ($d_1['carga_masiva'] == '0') {
                echo "<table align='center' border='0' cellpadding='0' cellspacing='2' style='border:#CCCCCC solid 1px;' width='250'>";
                $s_2 = "select * from scrap_partes where no_folio='{$d_1['no_folio']}' order by no_parte";
                $r_2 = mysql_query($s_2);
                while ($d_2 = mysql_fetch_array($r_2)) {
                    echo "<tr bgcolor='#EEEEEE'>";
                    echo "<td align='left' width='100'>&nbsp;{$d_2['no_parte']}</td>";
                    echo "<td align='left' width='150'>&nbsp;{$d_2['descripcion']}</td>";
                    echo "</tr>";
                }
                echo "</table>";
            }
            if ($d_1['carga_masiva'] == '1') {
                echo "<a href='../excel_reportes.php?op=ver_modelos&folio={$d_1['no_folio']}' class='menuLink'>";
                echo "Archivo de modelos<br>(carga masiva)</a>";
            }
            ?>
	</td>	
    <td align="center"><?php 
            echo $d_1['apd'];
            ?>
</td>
    <td align="left">&nbsp;&nbsp;<?php 
            echo $d_1['proyecto'];
            ?>
</td> 
    <td align="center"><?php 
            echo $d_1['empleado'];
            ?>
</td>	
    <?php 
            if ($_SESSION["DEPTO"] == 'inv') {
                ?>
	    <td align="center"><?php 
                echo get_bandera("lo", $d_1['no_folio']);
                ?>
</td>
		<td align="center"><?php 
                echo get_bandera("loa", $d_1['no_folio']);
                ?>
</td>
		<td align="center"><?php 
                echo get_bandera("lpl", $d_1['no_folio']);
                ?>
</td>
		<td align="center"><?php 
                echo get_bandera("ffm", $d_1['no_folio']);
                ?>
</td>
		<td align="center"><?php 
                echo get_bandera("ffc", $d_1['no_folio']);
                ?>
</td>
		<td align="center"><?php 
                echo get_bandera("prod", $d_1['no_folio']);
                ?>
</td>
		<td align="center"><?php 
                echo get_bandera("sqm", $d_1['no_folio']);
                ?>
</td>
        <td align="center"><?php 
                echo get_bandera("fin", $d_1['no_folio']);
                ?>
</td>
        <td align="center"><?php 
                echo get_bandera("esp", $d_1['no_folio']);
                ?>
</td>
        <td align="center"><?php 
                echo get_bandera("oes", $d_1['no_folio']);
                ?>
</td>
    	<td align="center"><?php 
                echo get_bandera("inv", $d_1['no_folio']);
                ?>
</td>
		<td align="center">
		<input type="button" class="submit_small" value="Aprobar" name="app" onclick="aprobar('<?php 
                echo $d_1['no_folio'];
                ?>
');" 
		 <?php 
                echo $dis;
                ?>
></td>
		<td align="center">
		<input type="button" class="submit_small" value="Rechazar" name="rech" onclick="rechazar('<?php 
                echo $d_1['no_folio'];
                ?>
');">
        </td>
		<td align="center">
		<input type="button" class="submit_small" value="Cancelar" name="canc" onclick="cancelar('<?php 
                echo $d_1['no_folio'];
                ?>
');">
        </td>	  
    <?php 
            } else {
                ?>
    <td align="center" width="60">
	<input type="button" class="submit_small" value="Aprobar" name="app" onclick="aprobar('<?php 
                echo $d_1['no_folio'];
                ?>
');"></td>
	<td align="center" width="60">
	<input type="button" class="submit_small" value="Rechazar" name="rech" onclick="rechazar('<?php 
                echo $d_1['no_folio'];
                ?>
');"></td>
</tr>
<?php 
            }
        }
        ?>
<tr bgcolor="#E6E6E6">
	<td colspan="<?php 
        echo $cols;
        ?>
" align="right" class="naranja"><b>Totales</b>&nbsp;&nbsp;</td>
	<td align="center" class="naranja"><b><?php 
        echo $qty;
        ?>
</b></td>
	<td align="right" class="naranja"><b><?php 
        echo "\$ " . number_format($cost, 2);
        ?>
</b>&nbsp;</td>
	<td colspan="18">&nbsp;</td>
</tr>
</tbody>
</table><br>
<div align="center">
	<input type="button" name="aprobar_todos" class="submit_big" value="Aprobar Seleccionados" onclick="app_sel();">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="button" name="rechazar_todos" class="submit_big" value="Rechazar Seleccionados" onclick="rech_sel();">
</div><br><br></form>
<?php 
    } else {
        echo "<div align='center' class='naranja'><b>Usted no tiene división, área, profit center o proyectos asignados como autorizador.<br>";
        echo "Contacte al administrador del sistema para que le asigne dichos filtros para ver las boletas correspondientes.<b></div>";
    }
}
Example #14
0
function reporte($fechai, $fechaf, $buscar, $filtros, $tipo)
{
    if (!$tipo) {
        $tipo = 'todos';
    }
    $s_ = "DROP VIEW vw_reportes_" . $_SESSION["IDEMP"];
    $r_ = mysql_query($s_);
    $s_1 = "select folios.*, sum(partes.cantidad) as cantidad_total, sum(partes.total) as costo_total from scrap_partes as partes, ";
    $s_1 .= "scrap_folios as folios, autorizaciones where folios.no_folio = partes.no_folio and autorizaciones.no_folio = ";
    $s_1 .= "folios.no_folio and autorizaciones.depto='{$_SESSION['DEPTO']}' ";
    switch ($tipo) {
        case "todos":
            if ($_SESSION["DEPTO"] == 'inv') {
                $s_1 .= " and (folios.status='0' or folios.status='2') and folios.activo='1' and ";
                $s_1 .= "autorizaciones.status='0' ";
            }
            if ($_SESSION["DEPTO"] != 'inv') {
                $s_1 .= " and folios.status='0' and folios.activo='1' and autorizaciones.status='0' ";
            }
            break;
        case "aprobados":
            $s_1 .= " and not exists (select no_folio from autorizaciones where status!='1' and folios.no_folio=";
            $s_1 .= "autorizaciones.no_folio and autorizaciones.depto!='inv') and ";
            $s_1 .= "folios.status='0' and folios.activo='1' and autorizaciones.status='0' ";
            break;
        case "cancelados":
            $s_1 .= " and (folios.status='0' or folios.status='2') and folios.activo='2' ";
        case "rechazados":
            $s_1 .= " and folios.status='2' and folios.activo='1' ";
            break;
        case "pendientes":
            $s_1 .= " and folios.status='0' and folios.activo='1' and autorizaciones.status='0' ";
            break;
    }
    for ($i = 0; $i <= 2; $i++) {
        if ($buscar[$i] != '' && $filtros[$i] != '') {
            $s_1 .= " and ( ";
            $data = split(",", $buscar[$i]);
            for ($j = 0; $j < count($data); $j++) {
                $s_1 .= get_operador($filtros[$i], $data[$j]) . " or ";
            }
            $s_1 = substr($s_1, 0, -3) . " ) ";
        }
    }
    if ($fechai != '' && $fechaf != '') {
        $s_1 .= "and (fecha>='{$fechai}' and fecha<='{$fechaf}') ";
    }
    $s_1 .= filtros_autorizador($division);
    $s_1 .= " group by no_folio order by no_folio DESC";
    $s_ = "CREATE OR REPLACE VIEW vw_reportes_" . $_SESSION["IDEMP"] . " AS " . $s_1;
    $r_ = mysql_query($s_);
}