<?php
require ("Conexion/Conexion.php");
require('lib/lib.php');
if(!isset($_SESSION['WEB2'])){
	echo "<script language='JavaScript'>location.href = 'index.php'</script>";
	die();
} else{
	Inactividad();
	if($_POST['Opcion'] != ''){
		if(preg_match("/^[[:digit:]]+$/", $_POST['Opcion'])){
			$Opcion = $_POST['Opcion'];
			$ClienteID = $_SESSION['ClienteID'];
			$FlotillaID = $_POST['FlotillaID'];
			$NoEconomico = $_POST['NoEconomico'];			
			if($Opcion == 1){
				if($FlotillaID != ''){
					if(preg_match("/^[[:digit:]]+$/", $FlotillaID)){
						$QueryCatalogo = mssql_query("SELECT * FROM Vehiculo WHERE VehiculoID = '$FlotillaID' AND ClienteID = '$ClienteID'");
						if(mssql_num_rows($QueryCatalogo) >= 1){
							$EvaluarCatalogo = mssql_fetch_array($QueryCatalogo);
							$Tabla = 1;
						}
					}else
						echo 'error4';
				}else
					echo 'error3';
			}
			elseif($Opcion == 2){
				if($NoEconomico != ''){
					if(preg_match("/^[ a-zA-Z\d.]{3,15}$/i", $NoEconomico)){
						$QueryCatalogo = mssql_query("SELECT * FROM Vehiculo WHERE NumeroEconomico = '$NoEconomico' AND ClienteID = '$ClienteID'");
						if(mssql_num_rows($QueryCatalogo) >= 1){
							$EvaluarCatalogo = mssql_fetch_array($QueryCatalogo);	
							$Tabla = 1;				
						}
					}else
						echo 'error6';
				}else
					echo 'error5';
			}
			if($Tabla == 1){ ?>
            <fieldset class="field">
              <legend class="lg">Información de la Flotilla.</legend>
              <table width="550" border="0" cellspacing="0" cellpadding="0" align="center">
                <tr>
                  <td width="69">&nbsp;</td>
                  <td width="481"><table width="450" border="0" cellspacing="0" cellpadding="0" align="center">
                    <tr>
                      <td width="107" align="left">&nbsp;</td>
                      <td width="162" align="left">&nbsp;</td>
                      <td width="95" align="left">&nbsp;</td>
                      <td width="186" align="left">&nbsp;</td>
                    </tr>
                    <tr>
                      <td colspan="2" align="left"><b>No. Flotilla:</b> <? echo ''.$EvaluarCatalogo['VehiculoID']; ?></td>
                      <td colspan="2" align="left"><b>No. Económico:</b> <? echo ''.$EvaluarCatalogo['NumeroEconomico']; ?></td>
                    </tr>
                    <tr>
                      <td colspan="2" align="left"><b>Nombre:</b> <? echo ''.$EvaluarCatalogo['Nombre']; ?></td>
                      <td colspan="2" align="left"><b>Departamento:</b> <? echo ''.$EvaluarCatalogo['Departamento']; ?></td>
                    </tr>
                    <tr>
                      <td colspan="2" align="left"><b>Identificación: </b><? echo ''.$EvaluarCatalogo['Identificacion']; ?></td>
                      <td colspan="2" align="left"><b>Status: </b><? echo ''.$EvaluarCatalogo['Estatus']; ?></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                  </table></td>
                </tr>
                <tr>
                  <td colspan="2"><table width="450" border="0" cellspacing="0" cellpadding="0" align="center">
                    <tr>
                      <td colspan="5" align="center" id="Titulo">Históricos</td>
                    </tr>
                    <tr>
                      <td width="128">&nbsp;</td>
                      <td width="39">&nbsp;</td>
                      <td width="71">&nbsp;</td>
                      <td width="164">&nbsp;</td>
                      <td width="48">&nbsp;</td>
                    </tr>
                    <tr>
                      <td align="left"><b>Ltrs. en el Día:</b></td>
                      <td align="right"><? echo $EvaluarCatalogo['ActualLTDia']; ?></td>
                      <td align="left">&nbsp;</td>
                      <td align="left"><b>Importe en el Día:</b></td>
                      <td align="right"><? echo '$ '.Number_Format($EvaluarCatalogo['ActualMNDia'], 2); ?></td>
                    </tr>
                    <tr>
                      <th align="left"><b>Ltrs. a la Semana:</b></th>
                      <td align="right"><? echo $EvaluarCatalogo['ActualLTSemana']; ?></td>
                      <td align="left">&nbsp;</td>
                      <th align="left"><b>Importe en la Semana:</b></th>
                      <td align="right"><? echo '$ '.Number_Format($EvaluarCatalogo['ActualMNSemana'], 2); ?></td>
                    </tr>
                    <tr>
                      <th align="left"><b>Ltrs. en el Mes:</b></th>
                      <td align="right"><? echo $EvaluarCatalogo['ActualLTMes']; ?></td>
                      <td align="left">&nbsp;</td>
                      <th align="left"><b>Importe en el Mes:</b></th>
                      <td align="right"><? echo '$ '.Number_Format($EvaluarCatalogo['ActualMNMes'], 2); ?></td>
                    </tr>
                    <tr>
                      <td align="left">&nbsp;</td>
                      <td align="left">&nbsp;</td>
                      <td align="left">&nbsp;</td>
                      <td align="left">&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                  </table>
                    <table width="450" border="0" cellspacing="0" cellpadding="0" align="center">
                      <tr>
                        <td colspan="5" align="center" id="Titulo">Limites</td>
                      </tr>
                      <tr>
                        <td width="131">&nbsp;</td>
                        <td width="36">&nbsp;</td>
                        <td width="73">&nbsp;</td>
                        <td width="165">&nbsp;</td>
                        <td width="45">&nbsp;</td>
                      </tr>
                      <tr>
                        <th align="left"><b>Ltrs. al Dia:</b></th>
                        <td align="right"><? echo $EvaluarCatalogo['LimiteLTDia']; ?></td>
                        <td align="right">&nbsp;</td>
                        <th align="left"><b>Importe al Día:</b></th>
                        <td align="right"><? echo '$ '.Number_Format($EvaluarCatalogo['LimiteMNDia'], 2); ?></td>
                      </tr>
                      <tr>
                        <th align="left"><b>Ltrs. a la Semana:</b></th>
                        <td align="right"><? echo $EvaluarCatalogo['LimiteLTSemana']; ?></td>
                        <td align="right">&nbsp;</td>
                        <th align="left"><b>Importe a la Semana:</b></th>
                        <td align="right"><? echo '$ '.Number_Format($EvaluarCatalogo['LimiteMNSemana'], 2); ?></td>
                      </tr>
                      <tr>
                        <th align="left"><b>Ltrs. al Mes:</b></th>
                        <td align="right"><? echo $EvaluarCatalogo['LimiteLTMes']; ?></td>
                        <td align="right">&nbsp;</td>
                        <th align="left"><b>Importe al Mes:</b></th>
                        <td align="right"><? echo '$ '.Number_Format($EvaluarCatalogo['LimiteMNMes'], 2); ?></td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                      </tr>
                  </table></td>
                </tr>
              </table>
            </fieldset>
            <?
			}else
				echo 'error7';						
		}else
			echo 'error2';
	}else
		echo 'error1';
}
?>
