示例#1
0
    function Busqueda($campo, $valor)
    {
        if ($campo == "nombre_remitente") {
            $where = $campo == "nombre_remitente" ? " AND remitentes.nombre_remitente like '%{$valor}%' " : "";
        } else {
            $where = $campo != "" ? " AND d.{$campo} like '%{$valor}%' " : "";
        }
        $sql_reg = "SELECT * FROM documentos d\r\n                Inner Join remitentes ON remitentes.id_remitente = d.id_remitente\r\n                Inner Join estados ON estados.id_estado = d.id_estado\r\n                Inner Join tipos_documento ON tipos_documento.id_tipo_documento = d.id_tipo_documento\r\n                " . $where . " ORDER BY d.id_documento DESC";
        $query_reg = new Consulta($sql_reg);
        ?>

<div class="ui-jqgrid ui-widget ui-widget-content ui-corner-all">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" id="tabla_despacho" class="gview_frmgrid">
	<tr>
		<td>
			<table width="100%" class="ui-jqgrid-htable" cellpadding="0" cellspacing="0">
				<tr bgcolor="#6699CC" class="ui-widget-header ui-th-column grid_resize" height="25">
					<th width="16%" class="ui-widget-header ui-th-column grid_resize">Reg. Nro</th>
					<th width="26%" class="ui-widget-header ui-th-column grid_resize">Remitente</th>
					<th width="28%" class="ui-widget-header ui-th-column grid_resize">Documento</th>
					<th width="13%" class="ui-widget-header ui-th-column grid_resize">Registrado</th>
					<th width="6%" class="ui-widget-header ui-th-column grid_resize">Estado</th>
					<th class="ui-widget-header ui-th-column grid_resize">Ubicacion  Original</th>
				</tr>			
			</table>
		</td>
	</tr>
	<tr class="ui-jqgrid-bdiv">
		<td>
			<table id="frmgrid" width="100%" class="ui-jqgrid-btable" cellpadding="0" cellspacing="0">

        <?php 
        while ($row_reg = $query_reg->ConsultaVerRegistro()) {
            $id = $row_reg[0];
            $estado = $row_reg["id_estado"];
            $tooltip = "";
            if (!empty($row_reg['asunto_documento'])) {
                $tooltip = "title ='" . $row_reg['asunto_documento'] . "' class='tip'";
            }
            ?>
        <tr class="ui-widget-content1 jqgrow <?php 
            echo $estado == 12 ? "Estilo2 fila_finalizada" : "Estilo2";
            ?>
">
            <td <?php 
            echo $tooltip;
            ?>
 width="16%">
				<div align="center">
				<?php 
            $cod = $row_reg[1];
            if ($estado != 12) {
                ?>
						<a href="escaneo_acceso_registro.php?opcion=edit&id=<?php 
                echo $id;
                ?>
">
						<?php 
                echo $cod;
                ?>
</a>
					 <?php 
            } else {
                echo $cod;
            }
            ?>
				</div>
			</td>
            <td width="26%">
				<input size="48"  value="<?php 
            echo $row_reg["nombre_remitente"];
            ?>
"/>
			</td>
            <td width="28%">
				<input size="43" value="<?php 
            echo $row_reg["numero_documento"];
            ?>
"/>
			</td>
            <td width="13%">
				<input name="text" type="text" style="text-align:center; width:100%" value="<?php 
            echo date('d/m/Y H:i', strtotime($row_reg['fecha_registro_documento']));
            ?>
" size="3"/>
			</td>
            <td width="6%" align="center">
				<input name="text2" type="text" style="text-align:center; width:100%" value="<?php 
            echo $row_reg['abrev_nombre_estado'];
            ?>
" size="3"/>
			</td>
            <?php 
            $sql_ultimo = "SELECT Max(`hd`.`id_historial_documento`) AS `ultimo`\r\n                            FROM\r\n                            `historial_documentos` AS `hd`\r\n                            where hd.id_documento='" . $row_reg['id_documento'] . "'\r\n                            GROUP BY\r\n                            `hd`.`id_documento`";
            $query_ultimo = new Consulta($sql_ultimo);
            $ultimo = $query_ultimo->ConsultaVerRegistro();
            $sql_data = " SELECT hd.id_documento,\r\n                            a.nombre_area,\r\n                            a.abve_nombre_area\r\n                            FROM historial_documentos AS hd\r\n                            Inner Join areas AS a ON a.id_area = hd.id_area\r\n                            where hd.id_historial_documento='" . $ultimo['ultimo'] . "'";
            $query_data = new Consulta($sql_data);
            $data = $query_data->ConsultaVerRegistro();
            $sql_usu = "SELECT Max(`ha`.`id_historial_atencion`) AS `ultimo`,\r\n                            `ha`.`id_documento`\r\n                            FROM `historial_atencion` AS `ha`\r\n                            WHERE ha.original_historial_atencion =  '1' and\r\n                            ha.id_documento='" . $row_reg['id_documento'] . "'\r\n                            GROUP BY\r\n                            `ha`.`id_documento`\t";
            $query_usu = new Consulta($sql_usu);
            $usu = $query_usu->ConsultaVerRegistro();
            $susu = "SELECT `u`.`login_usuario`, `a`.`abve_nombre_area`\r\n                        FROM `historial_atencion` AS `ha`\r\n                        Inner Join `usuarios` AS `u` ON `u`.`id_usuario` = `ha`.`id_usuario_destino`\r\n                        Inner Join `areas` AS `a` ON `a`.`id_area` = `u`.`id_area`\r\n                        WHERE\r\n                        `ha`.`id_historial_atencion` = '" . $usu['ultimo'] . "' ";
            $qusu = new Consulta($susu);
            $u = $qusu->ConsultaVerRegistro();
            ?>
            <td><div align="center">
              <?php 
            $documento = new Documento($row_reg['id_documento']);
            ?>
              <input name="text42" type="text" value="<?php 
            echo $documento->UltimaUbicacionReporte();
            ?>
" />
            </div></td>
        </tr>
        <?php 
        }
        ?>
		 </table>
		</td>
	</tr>
</table>
</div>
<?php 
    }
    function RegistraListado($ide)
    {
        if ($ide == '') {
            $sql_reg = "SELECT\r\n\t\t\t\t\td.id_documento,\r\n\t\t\t\t\td.codigo_documento,\r\n\t\t\t\t\tr.nombre_remitente,\r\n\t\t\t\t\td.numero_documento,\r\n\t\t\t\t\te.nombre_estado,\r\n\t\t\t\t\te.abrev_nombre_estado,\r\n\t\t\t\t\td.fecha_registro_documento,\r\n\t\t\t\t\td.id_estado,\r\n\t\t\t\t\td.asunto_documento\r\n\t\t\t\t\tFROM\r\n\t\t\t\t\tdocumentos AS d\r\n\t\t\t\t\tLEFT Join remitentes AS r ON r.id_remitente = d.id_remitente\r\n\t\t\t\t\tLEFT Join estados AS e ON e.id_estado = d.id_estado\r\n\t\t\t\t\tLEFT Join usuarios u ON d.id_usuario = u.id_usuario\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t(d.id_estado =  1 OR\r\n\t\t\t\t\td.id_estado =  5)\r\n\t\t\t\t\tAND u.id_anp = " . $_SESSION['session'][7] . "\r\n\t\t\t\t\tORDER BY\r\n\t\t\t\t\td.id_documento DESC";
            $query_reg = new Consulta($sql_reg);
        } else {
            $where = $ide == "LT" ? "" : "d.id_estado ={$ide} AND";
            $sql_reg = "SELECT\r\n\t\t\t\t\td.id_documento,\t\r\n\t\t\t\t\td.codigo_documento,\r\n\t\t\t\t\tr.nombre_remitente,\r\n\t\t\t\t\td.numero_documento,\r\n\t\t\t\t\te.nombre_estado,\r\n\t\t\t\t\te.abrev_nombre_estado,\r\n\t\t\t\t\td.fecha_registro_documento,\r\n\t\t\t\t\td.id_estado,\r\n\t\t\t\t\td.asunto_documento\r\n\t\t\t\t\tFROM\r\n\t\t\t\t\tdocumentos AS d\r\n\t\t\t\t\tLEFT Join remitentes AS r ON r.id_remitente = d.id_remitente\r\n\t\t\t\t\tLEFT Join usuarios u ON d.id_usuario = u.id_usuario\r\n\t\t\t\t\tInner Join estados AS e ON e.id_estado = d.id_estado \r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t{$where}\r\n\t\t\t\t\tu.id_anp = " . $_SESSION['session'][7] . "\r\n\t\t\t\t\tORDER BY\r\n\t\t\t\t\td.id_documento DESC";
            $query_reg = new Consulta($sql_reg);
        }
        ?>
	
<div class="ui-jqgrid ui-widget ui-widget-content ui-corner-all">	
	<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" id="tabla_despacho" class="gview_frmgrid">
	<tr>
	  <td>
			<table width="100%" class="ui-jqgrid-htable" cellpadding="0" cellspacing="0">
				<tr bgcolor="#6699CC" class="ui-widget-header ui-th-column grid_resize" height="25">
					<th width="16%" class="ui-widget-header ui-th-column grid_resize">Reg. Nro</th>
					<th width="27%" class="ui-widget-header ui-th-column grid_resize">Remitente</th>
					<th width="28%" class="ui-widget-header ui-th-column grid_resize">Documento</th>
					<th width="13%" class="ui-widget-header ui-th-column grid_resize">Registrado</th>
					<th width="6%" class="ui-widget-header ui-th-column grid_resize">Estado</th>
					<th class="ui-widget-header ui-th-column grid_resize">Ubicacion</th>
				</tr>			
			</table>
		    </td>
	</tr>
	<tr class="ui-jqgrid-bdiv">
		<td>
			<table id="frmgrid" width="100%" class="ui-jqgrid-btable" cellpadding="0" cellspacing="0">		
		<?php 
        while ($row_reg = $query_reg->ConsultaVerRegistro()) {
            $ids = $row_reg['id_documento'];
            $_POST[remi] = $row_reg['nombre_remitente'];
            $estado = $row_reg['id_estado'];
            $descripcion_dev = "";
            $clase = "Estilo7";
            if ($estado == 12) {
                $clase = "Estilo7 fila_finalizada";
            } else {
                $dias = resta_fechas(date("d/m/Y"), date('d/m/Y', strtotime($row_reg['fecha_registro_documento'])));
                if ($dias > 0) {
                    $clase = "Estilo7 fila_peligro";
                } else {
                    $clase = "Estilo7 fila_baja";
                }
            }
            if ($estado == 5) {
                $sql_dev = "SELECT\r\n                            v.descripcion,\r\n                            v.id_devuelto\r\n                            FROM\r\n                            devuelto AS v\r\n                            Inner Join documentos AS d ON v.id_documento = d.id_documento\r\n                            WHERE\r\n                            d.id_documento =  '{$ids}'\r\n                            ORDER BY\r\n                            v.id_devuelto DESC\r\n                            LIMIT 0, 1";
                $query_dev = new Consulta($sql_dev);
                $row_dev = $query_dev->VerRegistro();
                $descripcion_dev = $row_dev['descripcion'];
            }
            $tooltip_asunto = "";
            if (!empty($row_reg['asunto_documento'])) {
                $tooltip_asunto = "title ='" . $row_reg['asunto_documento'] . "' class='tip'";
            }
            ?>
	<tr class="ui-widget-content1 jqgrow <?php 
            echo $clase;
            ?>
">
    	<td <?php 
            echo $tooltip_asunto;
            ?>
 width="16%">
		<div align="center">
      <?php 
            $cod = $row_reg["codigo_documento"];
            if ($estado != 12 && $estado != 11) {
                ?>
              <a href="mesa_acceso_registro.php?opcion=despachar&ids=<?php 
                echo $ids;
                ?>
">
				<?php 
                echo $cod;
                ?>
              </a>
              <?php 
            } else {
                echo $cod;
            }
            ?>
			</div>    	</td>
		<td width="27%"><input size="40" value="<?php 
            echo $row_reg[nombre_remitente];
            ?>
"/></td>
    	<td width="28%"><input size="47" value="<?php 
            echo $row_reg[numero_documento];
            ?>
"/></td>
    	<td width="13%">		
			<div align="center">
				<input type="text" value="<?php 
            echo date('d/m/Y H:i', strtotime($row_reg['fecha_registro_documento']));
            ?>
" style="text-align:center;width:100%;"/>				
			</div>		</td>
    	<td align="center" <?php 
            if (!empty($descripcion_dev)) {
                echo "title ='" . $descripcion_dev . "' class='tip'";
            }
            ?>
 width="6%"><input name="text" type="text" style="text-align:center; width:100%" value="<?php 
            echo $row_reg['abrev_nombre_estado'];
            ?>
"/></td>
      	<td>	  
        <?php 
            $documento = new Documento($row_reg['id_documento']);
            ?>
		<input type="text" value="<?php 
            echo $documento->UltimaUbicacionReporte();
            ?>
" />     </td>
    </tr>
	<?php 
        }
        ?>
	</table>
	</td>
	</tr>
</table>
</div>

<?php 
    }