<?php
echo"<html>";
echo"<html onMouseOver=\"self.status='COURIER & MARKETING CIA LTDA '; return true\">";
echo '<script language="javascript">

window.moveTo(0,0);
window.resizeTo(screen.availWidth,screen.availHeight);
</script> ';
echo '<script src="js/jquery.js"></script> ';
echo '<script src="js/tiff.js"></script> ';
echo"<head>";
echo"<title>.::Sistema WEBSIM GAMA::. </title>";
echo"<meta name=\"author\" content='DESARROLLO WEB'>";
echo"<link rel='stylesheet' href='css/style.css' type=\"text/css\">";
echo"<link rel=\"SHORTCUT ICON\" href=imagenes/vc.png>";
echo"</head>";
echo"<body leftmargin=\"0\" topmargin=\"0\" marginheight=\"0\" marginwidth=\"0\" bgcolor=\"#ffffff\">";

include("conexion/conexion.php");
include("Menu/menu_inicio.php");
include("funciones/funciones_backup.php");
include("logos.php");

$guia = $_GET['guia'];
$prod = $_GET['prod'];
$pagina = 'VER DETALLE GUIA No ' . $guia;
?>
<style type="text/css">
    td.comment{
        padding:0pt;
        padding-bottom:0pt;
        margin:0pt;  
    }
    .comment{
        margin:0pt;	
        width:500px;
        height:auto !important;
        overflow:scroll !important;
    }
</style>
<CENTER>
    <form action="" method="POST" name="backup">
        <table width="800" border="0" class="primaria">
            <tr class=miTable_tr>
                <td colspan="7" class=miTable_th1><div align="center">..:: <? echo $pagina; ?> ::..</div></td>
            </tr>
            <?

            class guia_consulta {

                var $conexionObj2;

                function url_exists($url) {
                    $handle = @fopen($url, "r");
                    if ($handle === false)
                        return false;
                    fclose($handle);
                    return true;
                }

                function detalle_guia($tabla, $guia, $prod) {
                    include("logos.php");
                    $this->conexionObj2 = new conexion();
                    $this->conexionObj2->conectarse();
                    $rst_select_lotes = $this->conexionObj2->consultar("SELECT gp.id_conse, gp.guia, gp.tipo_guia, gp.id_estado, 
			           gp.id_devolucion, gp.id_cliente, 
					   gp.orden, gp.id_origen, gp.id_destino, gp.nom_zona, gp.cod_zona, gp.id_sucursal, 
					   gp.fecha_cargue, gp.hora_cargue, gp.id_mensajero,gp.id_impresion, gp.id_planilla,
					   gp.id_manifiesto, gp.id_usuario, gp.nom_cliente, gp.empresa, gp.destinatario, 
					   gp.direccion, gp.identificacion, gp.especial1, gp.especial2, gp.especial3, gp.especial4, 
					   gp.especial5,gp.especial6,gp.especial7,gp.especial8,gp.especial9,gp.especial10,
                                           gp.telefono, gp.ciudad, concat('/',gp.path)path,m.identificacion as cod_men, m.nombre as nom_men, s.nombre as nom_suc,
					   d.nombre as nom_dev, o.producto, e.nombre as nom_est, gp.cod_zona,gp.no_paquete                                          
				FROM guias_proceso as gp
					 inner join ordenes as o on (gp.orden=o.orden)
					 left outer join estados_gestion as e on (gp.id_estado=e.id_estado)
					 left outer join mensajeros as m on (gp.id_mensajero=m.id_mensajero)
					 left outer join sucursales as s on (gp.id_sucursal=s.id_sucursal)
					 left outer join devoluciones as d on (gp.id_devolucion=d.id_devolucion)					 
				WHERE gp.guia = '$guia'");

                    //z.nombre as nom_zona
                    //left outer join zonificacion_cs as z on (gp.cod_zona=z.codigo)
                    $perfil = $_SESSION['perfil'];
                    while ($row_select_lotes = mysql_fetch_array($rst_select_lotes)) {
                        echo "<tr class=miTable_tr>";
                        echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Tguia . "</td>";
                        echo "<td valign=top class=miTable_td>" . $row_select_lotes['guia'];

                        echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Tplanilla . "</td>";
                        echo "<td width=275  valign=top class=miTable_td>" . $row_select_lotes['id_planilla'] . "</td></tr>";
                        echo "</td></tr>";


                        echo "<tr class=miTable_tr>";
                        echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Torden . "</td>";
                        echo "<td valign=top class=miTable_td>" . $row_select_lotes['orden'];
                        echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Tdevolucion . "</td>";
                        echo "<td valign=top class=miTable_td>" . $row_select_lotes['nom_dev'] . "</td></tr>";
                        echo "</td></tr>";

                        echo "<tr class=miTable_tr>";
                        echo "<td width=100 valign=top height=42 class=miTable_th1>";
                         
                         if($_SESSION['id_user']=='45'){
    echo "PQR";
}else{
    echo $Tempresa;
}

                         echo "</td>";
                        echo "<td valign=top class=miTable_td>" . $row_select_lotes['empresa'];
                        echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Testado . "</td>";
                        echo "<td valign=top class=miTable_td>" . $row_select_lotes['nom_est'] . "</td></tr>";
                        echo "</td></tr>";

                        $f_entrega = '00-00-0000';
                        if (!empty($row_select_lotes['especial5']) and $row_select_lotes['especial5'] != '0000-00-00') {
                            $f_entrega = date("d-m-Y", strtotime($row_select_lotes['especial5']));
                        }
                        echo "<tr class=miTable_tr>";
                        echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Tdestinatario . "</td>";
                        echo "<td valign=top class=miTable_td>" . $row_select_lotes['destinatario'];
                        echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Tidentificacion . "</td>";
                        echo "<td valign=top class=miTable_td>" . $row_select_lotes['identificacion'] . "</td></tr>";
                        echo "</td></tr>";


                        echo "<tr class=miTable_tr>";
                        echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Tdireccion . "</td>";
                        echo "<td valign=top class=miTable_td>" . $row_select_lotes['direccion'];
                        echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Ttelefono . "</td>";
                        echo "<td valign=top class=miTable_td>" . $row_select_lotes['telefono'];
                        echo "</td></tr>";


                        echo "<tr class=miTable_tr>";
                        echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Tproducto . "</td>";
                        echo "<td valign=top class=miTable_td>" . $row_select_lotes['producto'];
                        echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Tzona . "</td>";
                        echo "<td valign=top class=miTable_td>" . $row_select_lotes['nom_zona'] . "</td></tr>";
                        echo "</td></tr>";


                        echo "<tr class=miTable_tr>";
                        echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Tciudad . "</td>";
                        echo "<td valign=top class=miTable_td>" . $row_select_lotes['ciudad'];
                        echo "<td width=100 valign=top height=42 class=miTable_th1>CODIGO ZONA</td>";
                        echo "<td valign=top class=miTable_td>" . $row_select_lotes['cod_zona'] . "</td></tr>";
                        echo "</td></tr>";

                        echo "<tr class=miTable_tr>";
                        echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Tmensajero . "</td>";
                        echo "<td valign=top class=miTable_td>" . $row_select_lotes['cod_men'];
                        if (!empty($Tespecial5)) {
                            echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Tespecial5 . "</td>";
                            echo "<td valign=top class=miTable_td>" . $f_entrega . "</td></tr>";
                        }
                        echo "</td></tr>";

                        echo "<tr class=miTable_tr>";
                        if (!empty($Tespecial1)) {
                            echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Tespecial1 . "</td>";
                            echo "<td valign=top class=miTable_td>" . $row_select_lotes['especial1'] . "</td>";
                        }
                        if (!empty($Tespecial2)) {
                            echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Tespecial2 . "</td>";
                            echo "<td valign=top class=miTable_td>" . $row_select_lotes['especial2'] . "</td></tr>";
                        }
                        echo "</td></tr>";


                        if (!empty($Tespecial3)) {
                            echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Tespecial3 . "</td>";
                            echo "<td valign=top class=miTable_td>" . $row_select_lotes['especial3'] . "</td>";
                        }

                        if (!empty($Tespecial4)) {
                            echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Tespecial4 . "</td>";
                            echo "<td valign=top class=miTable_td>" . $row_select_lotes['especial4'] . "</td>";
                        }
                        echo "</td></tr>";


                        if (!empty($Tespecial6)) {
                            echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Tespecial6 . "</td>";
                            echo "<td valign=top class=miTable_td>" . $row_select_lotes['especial6'] . "</td>";
                        }

                        if (!empty($Tespecial7)) {
                            echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Tespecial7 . "</td>";
                            echo "<td valign=top class=miTable_td>" . $row_select_lotes['especial7'] . "</td>";
                        }
                        echo "</td></tr>";

                        if (!empty($Tespecial8)) {
                            echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Tespecial8 . "</td>";
                            echo "<td valign=top class=miTable_td>" . $row_select_lotes['especial8'] . "</td>";
                        }

                        if (!empty($Tespecial9)) {
                            echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Tespecial9 . "</td>";
                            echo "<td valign=top class=miTable_td>" . $row_select_lotes['especial9'] . "</td>";
                        }
                        echo "</td></tr>";
                        if (!empty($Tespecial10)) {
                            echo "<td width=100 valign=top height=42 class=miTable_th1>" . $Tespecial10 . "</td>";
                            echo "<td valign=top class=miTable_td>" . $row_select_lotes['especial10'] . "</td>";
                        }


                        echo "<td width=100 valign=top height=42 class=miTable_th1>PAQUETE</td>";
                        echo "<td valign=top class=miTable_td>" . $row_select_lotes['no_paquete'] . "</td>";

                        echo "</td></tr>";

                        echo "<td>";
                        echo "<td>";

                        ##if($perfil!=5){

                        echo "</tr>";
                        ##}
                        ?>
                        <style type="text/css">
                            #container { position: relative; }
                            .mask { position: absolute; top: 0; left: 0; }
                        </style>
                        <CENTER>
                            <?
                            $sql_ip = "select ip_publica from info_empresa ";
                            $serv = ip_pub($sql_ip);
                            $ruta = $row_select_lotes['path'];
                            //$ruta2=trim($serv).trim($row_select_lotes['path']);
                            $rtatest = trim($row_select_lotes['path']);
                            $ruta2 = '..' . trim($row_select_lotes['path']);
					//echo $ruta2.'<br>';
                            if ($ruta == '') {
                                echo"<TABLE width='170' border=0>";
                                echo"<TR>";
                                echo"<th class=miTable_th1>Esta Guia No Posee Imagen";
                                echo "</th>";
                                echo"</TR>";
                                echo"</TABLE>";
                            } else {
                                if ($this->url_exists($ruta2)) {
                                    $fp = true;
                                } else {
                                    $fp = false;
                                }
                                if (!$fp) {

                                    $ruta2='';
                                        $sql_ip = "select direccion_ip,id from direccion_ip";
                                        $rst_ip = $this->conexionObj2->consultar($sql_ip);
                                        $row = mysql_num_rows($rst_ip);
                                        $v=true;
                                        if ($row > 0) {
                                            while ($row_ip = mysql_fetch_array($rst_ip)) {
                                                $id_ip = trim($row_ip['direccion_ip']);
                                                $id_ = trim($row_ip['id']);
                                                $img=str_replace('//192.157.230.32', '', $id_ip . $row_select_lotes['path']);
                                                $img=str_replace('//192.157.230.33', '', $img);
                                        $ruta2_ = "http://" . $img;
                                        $ruta2 .="<img src='" . $ruta2_ . "' border=1 width='$ancho' height='$altura px' title='GUIA No. $guia' >";
                                                //echo $id_;
                                                /*if($id_!=12){
                                                    $ImgTif = $id_ip . $row_select_lotes['path'];
                                                    //echo $ImgTif."<br>";
                                                    echo $_SERVER['HTTP_HOST'];
                                                    if($_SERVER['HTTP_HOST']=='181.48.164.6:8090'){
                                                       $ruta2 = "http://181.48.164.6:8040" . $row_select_lotes['path'];
                                                       $v=false;
                                                    }

                                                     if ($v) {  
                                                        $archivo = @fopen($ruta2, 'r');                                                               
                                                        if ($archivo ) {                                                
                                                            $fp = true;
                                                           // echo $ruta2;
                                                            fclose($archivo);
                                                            break;
                                                        }
                                                    }

                                                }elseif($id_==12){*/
                                                                                        
                                                        $fp = true;
                                                       
                                                   //     break;
                                                    
                                               // }
                                            }
                                        }
                                    }


                                if ($fp) {                                    
                                    @list($ancho, $altura, $tipo, $atr) = getimagesize($ruta2);
                                    echo"<TABLE width='$ancho' height='$altura px' border=0>";
                                    echo"<TR>";
                                    echo"<th>
					<div id=container>
";

echo "<div class='imgtif'></div>
						" . $ruta2 . "
					</div></div>";
                                    echo "</th>";
                                    echo"</TR>";
                                    echo"</TABLE>";
                                } else {
                                    echo"<TABLE width='170' border=0>";
                                    echo"<TR>";
                                    echo"<th class=miTable_th1>La Imagen no se encuentra en la ruta especificada. ";
                                    echo "</th>";
                                    echo"</TR>";
                                    echo"</TABLE>";

                                }
                            }
                            ?>
                        </CENTER>
                        <?PHP
                    }
                }

            }

            $guia_consultaObj = new guia_consulta();
            $guia_consultaObj->detalle_guia($tabla, $guia, $prod);
            ?>
            <center>
                <input type="button" value="Cerrar" onclick="self.close()" />
                <br>
                <br>
            </center>
        </table>
    </form>
</CENTER>
<?
echo"<table width=300 border=0 align=center cellpadding=0 cellspacing=0>";
echo"<tbody><tr>";
echo"<td></td>";
echo"</tr>";
echo"<tr>";
?>
<td>
<CENTER>
    <?
    pie_de_pagina();
    ?>
</CENTER>
</td>
<?php
echo"</tr>";
echo"</tbody></table>";
echo"</body>";
echo"</html>";
?>
