All pastes #1363356 Raw Edit

Something

public text v1 · immutable
#1363356 ·published 2009-03-17 14:35 UTC
rendered paste body
<?php
//   <!-- JRM 20060126: edicio de vehicles. -->
   define ('DEBUG', TRUE );
//   define ('DEBUG', FALSE );
   include('verificaPermisos.php');
   $perfil[1] = true;
   $perfil[2] = true;
   $perfil[3] = false;
   $perfil[4] = false;
   $perfil[5] = false;
   if (!verificaPermisos($perfil)) {
       header('Location: index.php');
       exit;
   }
   require('include.php');
   header('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1
   header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Data del passat
   header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');

   function insertaGrup($codi_vehicle, $grups) {
      global $objBd;
      $ret = true;
      $sSQL = 'DELETE FROM GRUP_VEHICLE WHERE CODI_VEHICLE = '.$codi_vehicle;
      if (DEBUG)
         echo '$sSQL : '.$sSQL.'<br />';
      if (!$objBd->consulta($sSQL))
         $ret = false;
      if (isset($grups) && !empty($grups)) {
         foreach ($grups as $clau => $valor) {
            $sSQL = 'INSERT INTO GRUP_VEHICLE (CODI_GRUP, CODI_VEHICLE) VALUES ('.$valor.', '.$codi_vehicle.')';
            if (DEBUG)
               echo '$sSQL : '.$sSQL.'<br />';
            if (!$objBd->consulta($sSQL))
               $ret = false;
         }
      }
      return $ret;
   }

   $smarty->assign('title', 'Editar vehiculo');
   $estil[] = 'css/forms.css';
   $smarty->assign('estil', $estil);
   $javascript[] = 'js/validacions.js';
   $javascript[] = 'js/valida_vehiculo.js';
   $smarty->assign('javascript', $javascript);
   if (isset($_SESSION['text_titol']))
      $smarty->assign('text_titol', $_SESSION['text_titol']);
   else
      $smarty->assign('text_titol', 'idsGpsWeb');
   if (isset($_SESSION['img_fons_titol']))
      $smarty->assign('img_fons_titol', $_SESSION['img_fons_titol']);
   else
      $smarty->assign('img_fons_titol', 'img/fons_roda.gif');
   $smarty->assign('usuari', $_SESSION['usuari']);
   $smarty->assign('perfil', $_SESSION['perfil']);
   $smarty->assign('estil_def', $_SESSION['fulla_estils_def']);
   $smarty->assign('fitxer_ajuda', $_SESSION['ayuda']);
   $smarty->display('cappag.tpl');				//mostra capalera
   include('validacions.php');						//validacions
   if (isset($_GET['idVehiculo']) && esNatural($_GET['idVehiculo'])) {
      $clean['idVehicle'] = $_GET['idVehiculo'];
//echo 'idVehiculo:'.$clean['idVehicle'].'<br />';
   } else if (isset($_POST['idVehiculo']) && esNatural($_POST['idVehiculo'])) {
      $clean['idVehicle'] = $_POST['idVehiculo'];
//echo 'idVehiculo:'.$clean['idVehicle'].'<br />';
   }
   
         
   // INICI EDICI TERMINAL
   
   //SI PITJEM L'OPCI DE GUARDAR, COMPROBA CAMPS ... ACTUALITZA SI EXISTEIX SINO INSERTA
   if (isset($_POST['opcio']) && ($_POST['opcio'] == 'Guarda')) {
   		// abans de guardar, ELS comproba  I ELS PASSA A PHP
      include_once('CnxFirebird.php');
      $objBd = new CnxFirebird('TRANSDAT'.$_SESSION['grup'].'.gdb');
      $error = '';
      //inici comprobacions del "GPS"
      if (isset($_POST['txtHoraIniPool'])) $clean['txtHoraIniPool']=$_POST['txtHoraIniPool'];
   	  	else $clean['txtHoraIniPool']=00;
   	  if (isset($_POST['txtMinIniPool'])) $clean['txtMinIniPool']=$_POST['txtMinIniPool'];
   	  	else $clean['txtMinIniPool']=00;
   	  if (isset($_POST['txtHoraFinPool'])) $clean['txtHoraFinPool']=$_POST['txtHoraFinPool'];
   	  	else $clean['txtHoraFinPool']=23;
   	  if (isset($_POST['txtMinFinPool'])) $clean['txtMinFinPool']=$_POST['txtMinFinPool'];
   	  	else $clean['txtMinFinPool']=59;
   		if (isset($_POST	['txtKM']) && strlen($_POST['txtKM'])>0) { $clean['distancia']=$_POST['txtKM'];
   			}
   			else $clean['distancia']=0;
   			
   		if (isset($_POST	['txtTiempo']) && strlen($_POST['txtKM'])>0) { $clean['gpstemps']=$_POST['txtTiempo'];
   			}
   			else $clean['distancia']=0;
   		//}ELSE 
      if (isset($_POST['ddlTipo']) && (strlen($_POST['ddlTipo']) > 0)) {
         $clean['tipus_terminal'] = '\''.utf8_decode(escapa_bd($_POST['ddlTipo'])).'\'';
      } else
         $clean['tipus_terminal'] = 'NULL'; 
      if (isset($_POST['txtTelefono']) && strlen($_POST['txtTelefono']) > 0) {
         if (esNatural($_POST['txtTelefono']) && strlen($_POST['txtTelefono']) >= 9)
            $clean['telefon'] = '\''.escapa_bd($_POST['txtTelefono']).'\'';
         else {
            if ($error <> '')
               $error .= '<br />&nbsp;';
            $error .= '- El tel&eacute;fono tiene que estar formado por almenos 9 n&uacute;meros.';
         }
      } else         
         if (isset($_POST['telefonocult'])) $clean['telefon'] =$_POST['telefonocult'];
         else $clean['telefon']= 'NULL';
      
      //fi comprobacions del "GPS"
      if (isset($_POST['txtMatricula']) && strlen($_POST['txtMatricula']) > 0) {
         $clean['matricula'] = '\''.utf8_decode(escapa_bd($_POST['txtMatricula'])).'\'';
      } else
         $error .= '- Tiene que entrar la matr&iacute;cula del veh&iacute;culo.';
      if (isset($_POST['txtNombreVehiculo']) && (strlen($_POST['txtNombreVehiculo']) > 0)) {
         $clean['nom_vehicle'] = '\''.utf8_decode(escapa_bd($_POST['txtNombreVehiculo'])).'\'';
      } else
         $clean['nom_vehicle'] = 'NULL';
      if (isset($_POST['txtObservaciones']) && strlen($_POST['txtObservaciones']) > 0) {
         $clean['observacions'] = '\''.utf8_decode(escapa_bd($_POST['txtObservaciones'])).'\'';
      } else
         $clean['observacions'] = 'NULL';
      if (isset($_POST['ddlOperario'])) {
         if ($_POST['ddlOperario'] == '---') {
            $clean['codi_operari'] = 'NULL';
         } else if ($_POST['ddlOperario'] == 'NUE') {
            $sSQL = 'INSERT INTO OPERARI (NOM) VALUES (\''.escapa_bd($_POST['txtOperario']).'\')';
            if ($objBd->consulta($sSQL)) {
               $sSQL = 'SELECT CODI FROM OPERARI WHERE NOM = \''.escapa_bd($_POST['txtOperario']).'\'';
               if (($objBd->consulta($sSQL)) && ($fila = $objBd->obte_fila(0, 1))) {
                  $clean['codi_operari'] = $fila['CODI'];
               }
            }
         } else if (esNatural($_POST['ddlOperario'])) {
            $clean['codi_operari'] = $_POST['ddlOperario'];
         } else
            $error .= '- Operario incorrecto.';  
      }
      if (isset($_POST['ddlGrupo']))
         $clean['grup'] = $_POST['ddlGrupo'];
      else
         $clean['grup'] = array();
      if (isset($_POST['radIcono']) && esNatural($_POST['radIcono'])) {
         $clean['radIcono'] = '\''.$_POST['radIcono'].'\'';
      } else
         $clean['radIcono'] = '\'1\'';
      //acaba de comprobar els camps, si $error no s null, hi ha errors, salta!!
      if (!($error == '')) {
            $smarty->assign('error', $error);
            $smarty->assign('solucio', 'Solucione los valores incorrectos.');
            $smarty->assign('email_soport', $_SESSION['email_soport']);
            $smarty->display('error.tpl');
            exit;
      }
      
       //actualitza camps
        $sSQLMARC='UPDATE OR INSERT INTO TERMINALS (CODITERMINAL, TIPUS, TELEFON,GPSDISTANCIA,GPSTEMPS) VALUES('.$clean['telefon'].',  '.$clean['tipus_terminal'].',  '.$clean['telefon'].',  '.$clean['distancia'].',  '.$clean['gpstemps'].') ';
if (DEBUG){    							$fn = "c:\\sqlout.txt";
 														$fn = fopen($fn, 'w') or die();
  													fwrite($fn, ">$sSQLMARC<\n");
														fclose($fn);
   													echo $sSQLMARC;
  }
    //$smarty->assign('sSQL', $sSQLMARC);
   if ($objBd->consulta($sSQLMARC)) {
   	?> <h1>GPS modificado</h1>  <?
  }
            
      /* modificaci de dades amb l'update DE VEHICLES */
      //SI TENIM IDENTIFICACI DE VEHICLE ... (SIGNIFICA QUE EXISTEIX!!!, LLAVORS ACTUALITZA DADES!!)
     
      if (isset($clean['idVehicle'])) {      	
      	if (DEBUG){      		
      	 					$sSQL = 'UPDATE VEHICLES SET MATRICULA = '.$clean['matricula'].', NOM_VEHICLE = '.$clean['nom_vehicle'].', ';
         					$sSQL .= 'OBSERVACIONS = '.$clean['observacions'].', CODI_OPERARI = '.$clean['codi_operari'].', TELEFON ='.$clean['telefon'].', '; 
         					$sSQL .= 'ICONA = '.$clean['radIcono'];
         					$sSQL .= 'WHERE CODI = '.$clean['idVehicle'];
         		//$sSQLMARC='UPDATE OR INSERT INTO TERMINALS (CODITERMINAL, TIPUS, TELEFON,GPSDISTANCIA,GPSTEMPS) VALUES('.$clean['telefon'].',  '.$clean['tipus_terminal'].',  '.$clean['telefon'].',  '.$clean['distancia'].',  '.$clean['gpstemps'].') ';
         					echo $sSQL;
        }
        else {        	
        			$sSQL = 'UPDATE VEHICLES SET MATRICULA = '.$clean['matricula'].', NOM_VEHICLE = '.$clean['nom_vehicle'].', ';
         			$sSQL .= 'OBSERVACIONS = '.$clean['observacions'].', CODI_OPERARI = '.$clean['codi_operari'].', TELEFON = '.$clean['telefon'].', '; 
         			$sSQL .= 'ICONA = '.$clean['radIcono'];         			
         			$sSQL .= 'WHERE CODI = '.$clean['idVehicle'];
        }
		  	//if (DEBUG) 
		  	//				$sSQL .=', TIPUS_TERMINAL = '.$clean['tipus_terminal'].' ';
         
         if (DEBUG)
            echo '$sSQL : '.$sSQL.'<br />';
         if ($objBd->consulta($sSQL)) {
            if (insertaGrup($clean['idVehicle'], $clean['grup'])) {	//AQUI ACTUALITZA I SI HA ANAT B, ESCRIU ENLLAOS PER TORNAR ..
               ?><h1>Registro modificado</h1>
               <div class="body"><a href="vehiculo_editar.php?idVehiculo=<?php echo $clean['idVehicle']; ?>">Volver al registro</a></div>
               <div class="body"><a href="<?php echo $_SESSION['ultim_llistat']; ?>">Volver al listado</a></div><?php
            } else {
               $smarty->assign('error','Error al tractar los grupos del veh&iacute;culo.');
               $smarty->assign('solucio','Compruebe los datos de los grupos.');
               $smarty->assign('email_soport', $_SESSION['email_soport']);
               $smarty->display('error.tpl');
               exit;
            }
         } else {
            $smarty->assign('error','Error al modificar el registro.');
            $smarty->assign('solucio','Compruebe que los datos entrados sean correctos.');
            $smarty->assign('email_soport', $_SESSION['email_soport']);
            $smarty->display('error.tpl');
            exit;
         }
      } else {
         $smarty->assign('error','Error al buscar el veh&iacute;culo que modificar.');
         $smarty->assign('solucio','Compruebe que los datos entrados sean correctos.');
         $smarty->assign('email_soport', $_SESSION['email_soport']);
         $smarty->display('error.tpl');
         exit;
      }
      /*fi modificaci de dades*/
   } else {
   	//SI CARRAGUEM, BUSQUEM ELS VEHICLES AMB EL CODI $clean['idVehicle]
      if (isset($clean['idVehicle'])) {
      	 $sSQL = 'SELECT VEHICLES.CODI, VEHICLES.IMEI, VEHICLES.TIPUS_TERMINAL, VEHICLES.TELEFON, VEHICLES.MATRICULA, TERMINALS.TIPUS, ';
         $sSQL .= 'VEHICLES.NOM_VEHICLE, VEHICLES.ICONA, VEHICLES.OBSERVACIONS, VEHICLES.DATABAIXA, VEHICLES.CODI_OPERARI ';
         $sSQL .= 'FROM VEHICLES ';
         $sSQL .= 'LEFT JOIN TERMINALS ON  TERMINALS.TIPUS=VEHICLES.TIPUS_TERMINAL  '; //girat abans era  VEHICLES.TIPUS_TERMINAL=TERMINALS.TIPUS
         $sSQL .= 'WHERE VEHICLES.CODI = '.$clean['idVehicle'];
         if (DEBUG)
            echo '$sSQL : '.$sSQL.'<br />';
         include_once('CnxFirebird.php');
         $objBd = new CnxFirebird('TRANSDAT'.$_SESSION['grup'].'.gdb');
         if ($objBd->consulta($sSQL)) {
            if ($fila = $objBd->obte_fila(0, 1)) {
            	//carrega les dades de la consulta, per mostrar-les
            	 $vehicle['telefon']=$fila['TELEFON'];		//Modificaci telefon marc
            	 $vehicle['tipus_terminal']=$fila['TIPUS_TERMINAL']; //MODIFICACIO tipus terminal MARC
               $vehicle['codi'] = $fila['CODI'];
               $vehicle['imei'] = $fila['IMEI'];
               $vehicle['matricula'] = utf8_encode($fila['MATRICULA']);
               $vehicle['nom_vehicle'] = utf8_encode($fila['NOM_VEHICLE']);
               $vehicle['icona'] = $fila['ICONA'];
               $vehicle['observacions'] = utf8_encode($fila['OBSERVACIONS']);
               $vehicle['codi_operari'] = $fila['CODI_OPERARI'];
               //for ( $i=0; $i< count($fila); $i ++) echo 'lloc '.$i.' = '.$fila[$i].'..<br/>';
               if (is_null($fila['DATABAIXA']))
                  $vehicle['baixa'] = false;
               else
                  $vehicle['baixa'] = true;
            } else {
            	//si no troba el vehicle, llena error!!
               $smarty->assign('error','Error con BDD. No se encuentra dicho vehiculo.');
               $smarty->assign('solucio','Compruebe los datos.');
               $smarty->assign('email_soport', $_SESSION['email_soport']);
               $smarty->display('error.tpl');
               exit;
            }
         } else {
            $smarty->assign('error','Error con BDD al consultar el vehiculo.');
            $smarty->assign('solucio','Pru&eacute;belo m&aacute;s tarde.');
            $smarty->assign('email_soport', $_SESSION['email_soport']);
            $smarty->display('error.tpl');
            exit;         
         }
      }
   if (isset($vehicle['codi'])) {
   			//si el vehicle t codi escrius ...
   			//comprobacions(1);
      //<form style="padding: 1em 2em;" action="<?php echo $_SERVER['PHP_SELF']; ? >" method="post" onsubmit="return comprovacionesVehiculo(1);">
      //<form style="padding: 1em 2em;" action="<?php echo $_SERVER['PHP_SELF']; ? >" method="post" onsubmit="return comprovacioTelefon(1);">
      ?><form style="padding: 1em 2em;" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" onsubmit="return comprobacions(1);" name="FDadesV">
         <div class="div_form">
      <h1>Modificaci&oacute;n de un veh&iacute;culo</h1>
      <input type="hidden" name="idVehiculo" value="<?php echo $vehicle['codi']; ?>" /><?php
   } else {
      $smarty->assign('error', 'Debe especificar un veh&iacute;culo que modificar.');
      $smarty->assign('solucio', 'Compruebe que los datos entrados sean correctos.');
      $smarty->assign('email_soport', $_SESSION['email_soport']);
      $smarty->display('error.tpl');
      exit;
   }
   
if (DEBUG) {
   ?>
<!-- < ?php  INICI COMENTAT GPS -->
 <? 
 //if (DEBUG)echo "idvehicle =".$clean['idVehicle'];
 ?>
      <fieldset>
      <legend >Configuraci&oacute;n de Terminal</legend>
         <label for="ddlTipo">Tipo de terminal:</label>
         <br/>
         
         <select id="ddlTipo" title="Escoja el tipo de terminal que utiliza el equipo" name="ddlTipo" size="3">
         		<?php if(isset($vehicle['tipus_terminal'])){  	?>
     							<option value="ROV9" <?php if	($vehicle['tipus_terminal'] == 'ROV9'){ 	echo 'selected="selected"'; ?> >ROVER 9</option>
																			 <?php } else	{  ?>  >ROVER9</option> <?php  } ?>
									<option value="DAT5" <?php if	($vehicle['tipus_terminal'] == 'DAT5'){ echo 'selected="selected"'; ?> >DAT5</option>
																					<?php }	else { ?>  >DAT5</option>   <?php  }  ?>
									<option value="DAT2" <?php if	($vehicle['tipus_terminal'] == 'DAT2'){ 	echo 'selected="selected"'; ?> >DAT2</option>
																						<?php }	else	{	 ?>  >DAT2</option> 	
						<?php   }  }
            			else { ?>	
            			<option value="ROV9" <?php if	($vehicle['tipus_terminal'] == 'ROV9'){ echo 'selected="selected"'; ?> >ROVER 9</option>
     												      			 <?php } else	{ ?>  >ROVER9</option> <?php  } ?>
									<option value="DAT5" <?php if	($vehicle['tipus_terminal'] == 'DAT5'){ echo 'selected="selected"'; ?> >DAT5</option>
																				<?php }	else	{ ?>  >DAT5</option>   <?php  }  ?>
									<option value="DAT2" <?php if	($vehicle['tipus_terminal'] == 'DAT2'){ echo 'selected="selected"'; ?> >DAT2</option>
																						<?php }	else{  ?>  >DAT2</option> <?php   }            	
            }
            ?>
         </select>
         <br />
         <label for="txtTelefono">Tel&eacute;fono:</label>
         <br />
         <input type="text" title="Introduce tu tel&eacute;fono" maxlength="15" size="15" name="txtTelefono" id="txtTelefono" value="<?php if (isset($vehicle['telefon'])) echo $vehicle['telefon']; ?>" /><br/>
         <?
         //consulta dades terminals si hi ha telefon assignat ?
         //if (DEBUG)echo "telefon = ".$vehicle['telefon'];
           ?>
<!-- < ?php COMENTAT GPS 
         <br />-->
         
         <label for="txtKM">Distancia:</label>
         <br />
         <input type="text" title="Introduce km para programar por distancia" maxlength="5" size="5" name="txtKM" id="txtKM" value="<?php if (isset($clean['txtKM'])) echo $clean['txtKM']; else echo 0;?>" />
         <br />
         <label for="txtTiempo">Tiempo:</label>
         <br />
         <input type="text" title="Introduce los segundos entre posiciones enviadas" maxlength="5" size="5" name="txtTiempo" id="txtTiempo" value="<?php if (isset($clean['txtTiempo'])) echo $clean['txtTiempo']; else echo 0;?>" />
         <br />
         <label for="txtHoraIniPool">Hora inicio pooling:</label>
         <br />
         <input type="text" title="Introduce la hora desde la que se permite enviar la posici&oacute;n" maxlength="2" size="2" name="txtHoraIniPool" id="txtHoraIniPool" value="<?php if (isset($clean['txtHoraIniPool'])) echo $clean['txtHoraIniPool']; else echo 00;?>" /> :
         <input type="text" title="Introduce los minutos desde los que se permite enviar la posici&oacute;n" maxlength="2" size="2" name="txtMinIniPool" id="txtMinIniPool" value="<?php if (isset($clean['txtMinIniPool'])) echo $clean['txtMinIniPool']; else echo 00;?>" />
         <br />
         <label for="txtHoraFinPool">Hora fin pooling:</label>
         <br />
         <input type="text" title="Introduce la hora hasta la que se permite enviar la posici&oacute;n" maxlength="2" size="2" name="txtHoraFinPool" id="txtHoraFinPool" value="<?php if (isset($clean['txtHoraFinPool'])) echo $clean['txtHoraFinPool']; else echo 23;?>" /> :
         <input type="text" title="Introduce los minutos hasta los que se permite enviar la posici&oacute;n" maxlength="2" size="2" name="txtMinFinPool" id="txtMinFinPool" value="<?php if (isset($clean['txtMinFinPool'])) echo $clean['txtMinFinPool']; else echo 59;?>" />
         <br />
         <div class="label">Dias pooling:</div>
         <input type="checkbox" checked="checked" title="Escoja que dias se permite enviar la posici&oacute;n" name="chkDiasPool_1" id="chkDiasPool_1" value="1" />
         <label for="chkDiasPool_1">Lu</label>
         &nbsp;
         <input type="checkbox" checked="checked" title="Escoja que dias se permite enviar la posici&oacute;n" name="chkDiasPool_2" id="chkDiasPool_2" value="2" />
         <label for="chkDiasPool_2">Ma</label>
         &nbsp;
         <input type="checkbox" checked="checked" title="Escoja que dias se permite enviar la posici&oacute;n" name="chkDiasPool_3" id="chkDiasPool_3" value="3" />
         <label for="chkDiasPool_3">Mi</label>
         &nbsp;
         <input type="checkbox" checked="checked" title="Escoja que dias se permite enviar la posici&oacute;n" name="chkDiasPool_4" id="chkDiasPool_4" value="4" />
         <label for="chkDiasPool_4">Ju</label>
         &nbsp;
         <input type="checkbox" checked="checked" title="Escoja que dias se permite enviar la posici&oacute;n" name="chkDiasPool_5" id="chkDiasPool_5" value="5" />
         <label for="chkDiasPool_5">Vi</label>
         &nbsp;
         <input type="checkbox" title="Escoja que dias se permite enviar la posici&oacute;n" name="chkDiasPool_6" id="chkDiasPool_6" value="6" />
         <label for="chkDiasPool_6">Sa</label>
         &nbsp;
         <input type="checkbox" title="Escoja que dias se permite enviar la posici&oacute;n" name="chkDiasPool_7" id="chkDiasPool_7" value="7" />
         <label for="chkDiasPool_7">Do</label>
         <br />
         <label for="txtTest">Test:</label>
         <br />
         <input type="text" title="Introduce cada cuantos segundos quieres que envie un test" maxlength="7" size="7" name="txtTest" id="txtTest" value="<?php if (isset($clean['txtTiempo'])) echo $clean['txtTest']; else echo 0;?>" />
         <br />
         <!--
         s'han de posar consums ...
         -->
         <label for="txtKMCR">Consumo en carretera:</label><br/>
         <input type="text" title="Introduce el consumo en % en 100 kilometros del vehiculo" maxlength="3" size="3" name="txtKMCR" id="txtKM" value="0" /><br/>
         <label for="txtKMA">Consumo en autopista:</label><br/>
         <input type="text" title="Introduce el consumo en % en 100 kilometros del vehiculo" maxlength="3" size="3" name="txtKMA" id="txtKM" value="0" /><br/>
         <label for="txtKMC">Consumo en ciudad:</label><br/>
         <input type="text" title="Introduce el consumo en % en 100 kilometros del vehiculo" maxlength="3" size="3" name="txtKMC" id="txtKM" value="0" /><br/>
         <label for="txtKMP">Precio combustible:</label><br/>
         <input type="text" title="Introduce el precio del combustible del vehiculo" maxlength="3" size="3" name="txtPC" id="txtKMP" value="0" /><br />
         
    <!-- BOTO GUARDA GPS 
         <input accesskey="G" style="margin-right: 4em;" type="submit" name="opcioT" value="Guardar" /> -->
      </fieldset>
      <? 
  } 
  ?>
<!--       
FI COMENTAT GPS
  ?> -->
      <div>
      	<input type="hidden" title="Introduce tu tel&eacute;fono" maxlength="15" size="15" name="telefonocult" id="txtTelefono" value="<?php if (isset($vehicle['telefon'])) echo $vehicle['telefon']; ?>" /><br/>
      
      
         <label accesskey="M" for="txtMatricula">Matr&iacute;cula</label>
         <br />
         <input type="text" title="Introduce la matr&iacute;cula del veh&iacute;culo"  maxlength="15" size="8" name="txtMatricula" id="txtMatricula" maxlength="8" value="<?php if (isset($vehicle['matricula'])) echo $vehicle['matricula']; ?>" />
         <br />
         <label accesskey="N" for="txtNombreVehiculo">Nombre veh&iacute;culo</label>
         <br />
         <input type="text" title="Introduce una breve descripci&oacute;n del veh&iacute;culo" maxlength="40" size="40"  name="txtNombreVehiculo" id="txtNombreVehiculo" value="<?php if (isset($vehicle['nom_vehicle'])) echo $vehicle['nom_vehicle']; ?>" />
         <br />
<script type="text/javascript">
<!--
   function mirarNuevo(sel) {
      if (sel.selectedIndex == 1)
         document.getElementById('txtOperario').style.visibility = 'visible';
      else
         document.getElementById('txtOperario').style.visibility = 'hidden';
   }
-->
</script>
         <label accesskey="O" for="ddlOperario">Operario:</label>
         <br/>
         <select id="ddlOperario" title="Escoja un operario" name="ddlOperario" onchange="mirarNuevo(this);">
            <option value="---">Ninguno</option>
            <option value="NUE">Entrar uno nuevo</option><?php
            include_once('CnxFirebird.php');
            $objBd = new CnxFirebird('TRANSDAT'.$_SESSION['grup'].'.gdb');
            $sSQL = 'SELECT CODI, NOM FROM OPERARI WHERE DATABAIXA IS NULL';
            if ($objBd->consulta($sSQL)) {
               while ($fila = $objBd->obte_fila(0, 1)) {
                   ?><option value="<?php echo $fila['CODI']; ?>" <?php if (isset($vehicle['codi_operari']) && ($vehicle['codi_operari'] == $fila['CODI'])) echo 'selected="selected"'; ?>><?php echo htmlentities($fila['NOM']); ?></option><?php
               }
            }
         ?></select>
         <input style="visibility: hidden;" type="text" title="Introduce el nombre del nuevo operario" maxlength="15" size="15" name="txtOperario" id="txtOperario" value="" />
         <br />
         <div class="label">Icono:</div>
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_1" value="1" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '1') echo 'checked="checked"' ?> />
         <label accesskey="D" for="radIcono_1"><img style="border: 0px;" src="img/gps/1.gif" width="32" height="25" alt="icono 1" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_2" value="2" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '2') echo 'checked="checked"' ?> />
         <label for="radIcono_2"><img style="border: 0px;" src="img/gps/2.gif" width="32" height="25" alt="icono 2" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_3" value="3" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '3') echo 'checked="checked"' ?> />
         <label for="radIcono_3"><img style="border: 0px;" src="img/gps/3.gif" width="32" height="25" alt="icono 3" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_4" value="4" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '4') echo 'checked="checked"' ?> />
         <label for="radIcono_4"><img style="border: 0px;" src="img/gps/4.gif" width="32" height="25" alt="icono 4" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_5" value="5" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '5') echo 'checked="checked"' ?> />
         <label for="radIcono_5"><img style="border: 0px;" src="img/gps/5.gif" width="32" height="25" alt="icono 5" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_6" value="6" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '6') echo 'checked="checked"' ?> />
         <label for="radIcono_6"><img style="border: 0px;" src="img/gps/6.gif" width="32" height="25" alt="icono 6" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_7" value="7" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '7') echo 'checked="checked"' ?> />
         <label for="radIcono_7"><img style="border: 0px;" src="img/gps/7.gif" width="32" height="25" alt="icono 7" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_8" value="8" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '8') echo 'checked="checked"' ?> />
         <label for="radIcono_8"><img style="border: 0px;" src="img/gps/8.gif" width="32" height="25" alt="icono 8" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_9" value="9" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '9') echo 'checked="checked"' ?> />
         <label for="radIcono_9"><img style="border: 0px;" src="img/gps/9.gif" width="32" height="25" alt="icono 9" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_10" value="10" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '10') echo 'checked="checked"' ?> />
         <label for="radIcono_10"><img style="border: 0px;" src="img/gps/10.gif" width="32" height="25" alt="icono 10" title="Icono" /></label>&nbsp;<br/>
     
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_11" value="11" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '11') echo 'checked="checked"' ?> />
         <label for="radIcono_11"><img style="border: 0px;" src="img/gps/11.gif" width="32" height="25" alt="icono 11" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_12" value="12" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '12') echo 'checked="checked"' ?> />
         <label for="radIcono_12"><img style="border: 0px;" src="img/gps/12.gif" width="32" height="25" alt="icono 12" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_13" value="13" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '13') echo 'checked="checked"' ?> />
         <label for="radIcono_13"><img style="border: 0px;" src="img/gps/13.gif" width="32" height="25" alt="icono 13" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_14" value="14" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '14') echo 'checked="checked"' ?> />
         <label for="radIcono_14"><img style="border: 0px;" src="img/gps/14.gif" width="32" height="25" alt="icono 14" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_15" value="15" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '15') echo 'checked="checked"' ?> />
         <label for="radIcono_15"><img style="border: 0px;" src="img/gps/15.gif" width="32" height="25" alt="icono 15" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_16" value="16" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '16') echo 'checked="checked"' ?> />
         <label for="radIcono_16"><img style="border: 0px;" src="img/gps/16.gif" width="32" height="25" alt="icono 16" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_17" value="17" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '17') echo 'checked="checked"' ?> />
         <label for="radIcono_17"><img style="border: 0px;" src="img/gps/17.gif" width="32" height="25" alt="icono 17" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_18" value="18" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '18') echo 'checked="checked"' ?> />
         <label for="radIcono_18"><img style="border: 0px;" src="img/gps/18.gif" width="32" height="25" alt="icono 18" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_19" value="19" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '19') echo 'checked="checked"' ?> />
         <label for="radIcono_19"><img style="border: 0px;" src="img/gps/19.gif" width="32" height="25" alt="icono 19" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_20" value="20" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '20') echo 'checked="checked"' ?> />
         <label for="radIcono_20"><img style="border: 0px;" src="img/gps/20.gif" width="32" height="25" alt="icono 20" title="Icono" /></label>&nbsp;<br/>
<!--
     inici furgonetes
     -->
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_25" value="31" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '31') echo 'checked="checked"' ?> />
         <label for="radIcono_31"><img style="border: 0px;" src="img/gps/31.gif" width="32" height="25" alt="furgoneta_1" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_26" value="32" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '32') echo 'checked="checked"' ?> />
         <label for="radIcono_32"><img style="border: 0px;" src="img/gps/32.gif" width="32" height="25" alt="furgoneta_2" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_27" value="33" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '33') echo 'checked="checked"' ?> />
         <label for="radIcono_33"><img style="border: 0px;" src="img/gps/33.gif" width="32" height="25" alt="furgoneta_3" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_28" value="34" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '34') echo 'checked="checked"' ?> />
         <label for="radIcono_34"><img style="border: 0px;" src="img/gps/34.gif" width="32" height="25" alt="furgoneta_4" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_29" value="35" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '35') echo 'checked="checked"' ?> />
         <label for="radIcono_35"><img style="border: 0px;" src="img/gps/35.gif" width="32" height="25" alt="furgoneta_5" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_30" value="36" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '36') echo 'checked="checked"' ?> />
         <label for="radIcono_36"><img style="border: 0px;" src="img/gps/36.gif" width="32" height="25" alt="furgoneta_6" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_31" value="37" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '37') echo 'checked="checked"' ?> />
         <label for="radIcono_37"><img style="border: 0px;" src="img/gps/37.gif" width="32" height="25" alt="furgoneta_7" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_32" value="38" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '38') echo 'checked="checked"' ?> />
         <label for="radIcono_38"><img style="border: 0px;" src="img/gps/38.gif" width="32" height="25" alt="furgoneta_8" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_33" value="39" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '39') echo 'checked="checked"' ?> />
         <label for="radIcono_39"><img style="border: 0px;" src="img/gps/39.gif" width="32" height="25" alt="furgoneta_9" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_34" value="40" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '40') echo 'checked="checked"' ?> />
         <label for="radIcono_40"><img style="border: 0px;" src="img/gps/40.gif" width="32" height="25" alt="furgoneta_10" title="Icono" /></label>&nbsp;<br/>
    <!--
    fi furgonetes
    -->         
     <!--
     inici remolcs
     -->
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_21" value="21" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '21') echo 'checked="checked"' ?> />
         <label for="radIcono_21"><img style="border: 0px;" src="img/gps/21.gif" width="32" height="25" alt="remolc_21" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_22" value="22" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '22') echo 'checked="checked"' ?> />
         <label for="radIcono_22"><img style="border: 0px;" src="img/gps/22.gif" width="32" height="25" alt="remolc_22" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_23" value="23" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '23') echo 'checked="checked"' ?> />
         <label for="radIcono_23"><img style="border: 0px;" src="img/gps/23.gif" width="32" height="25" alt="remolc_23" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_24" value="24" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '24') echo 'checked="checked"' ?> />
         <label for="radIcono_24"><img style="border: 0px;" src="img/gps/24.gif" width="32" height="25" alt="remolc_24" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_25" value="25" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '25') echo 'checked="checked"' ?> />
         <label for="radIcono_35"><img style="border: 0px;" src="img/gps/25.gif" width="32" height="25" alt="remolc_25" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_26" value="26" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '26') echo 'checked="checked"' ?> />
         <label for="radIcono_36"><img style="border: 0px;" src="img/gps/26.gif" width="32" height="25" alt="remolc_26" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_27" value="27" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '27') echo 'checked="checked"' ?> />
         <label for="radIcono_37"><img style="border: 0px;" src="img/gps/27.gif" width="32" height="25" alt="remolc_27" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_28" value="28" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '28') echo 'checked="checked"' ?> />
         <label for="radIcono_38"><img style="border: 0px;" src="img/gps/28.gif" width="32" height="25" alt="remolc_28" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_29" value="29" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '29') echo 'checked="checked"' ?> />
         <label for="radIcono_39"><img style="border: 0px;" src="img/gps/29.gif" width="32" height="25" alt="remolc_29" title="Icono" /></label>
         &nbsp;
         <input type="radio" title="Escoja uno de estos iconos" name="radIcono" id="radIcono_30" value="30" <?php if (isset($vehicle['icona']) && $vehicle['icona'] == '30') echo 'checked="checked"' ?> />
         <label for="radIcono_40"><img style="border: 0px;" src="img/gps/30.gif" width="32" height="25" alt="remolc_30" title="Icono" /></label>&nbsp;<br/>
         &nbsp;
    <!--
    fi remolcs
    -->
         <label accesskey="B" for="txtObservaciones">Observaciones:</label>
         <br />
         <input type="text" title="Introduce observaciones para dicho veh&iacute;culo" 	 maxlength="255" size="80" name="txtObservaciones" id="txtObservaciones" value="<?php if (isset($vehicle['observacions'])) echo $vehicle['observacions']; ?>" />
         <br />
         <label accesskey="G" for="ddlGrupo">Grupo/s:</label>
         <br/>
         <div>
         <select style="width: 150px;" id="ddlGrupo" title="Escoja uno o varios grupo/s" name="ddlGrupo[]" size="5" multiple="multiple"><?php
            include_once('CnxFirebird.php');
            $objBd = new CnxFirebird('TRANSDAT'.$_SESSION['grup'].'.gdb');
            if (isset($clean['idVehicle'])) {
               $sSQL = 'SELECT CODI, NOM, CODI_GRUP ';
               $sSQL .= 'FROM GRUP LEFT JOIN GRUP_VEHICLE ';
               $sSQL .= 'ON GRUP_VEHICLE.CODI_VEHICLE = '.$clean['idVehicle'].' ';
               $sSQL .= 'AND GRUP_VEHICLE.CODI_GRUP = GRUP.CODI';
            } else {
	           $sSQL = 'SELECT CODI, NOM, NULL AS CODI_GRUP FROM GRUP';
            }
            if ($objBd->consulta($sSQL)) {
               while ($fila = $objBd->obte_fila(0, 1)) {
                   if (!is_null($fila['CODI_GRUP']))
                      echo '<option value="'.$fila['CODI'].'" selected="selected">'.$fila['NOM'].'</option>';
                   else
                      echo '<option value="'.$fila['CODI'].'">'.$fila['NOM'].'</option>';
               }
            }
         ?></select> <div>(Mantenga pulsada la tecla 'CONTROL' mientras clica para seleccionar m&uacute;ltiples grupos o desseleccionar alguno)</div>
         </div>
         <br />
         <div class="label"><?php if (isset($vehicle['baixa']) && $vehicle['baixa']) { ?>El veh&iacute;culo est&aacute; de baja<?php } else { ?>El veh&iacute;culo est&aacute; activo<?php } ?></div>
         <br />
         <label for="txtImei">IMEI:</label>
         <input type="text" name="txtIMEI"  value="<?php if (isset($vehicle['imei'])) echo $vehicle['imei']; ?>" size=14 maxlength="14">
      </div>
      </div>
         <br />
         <div  style="text-align: center;">
            <input accesskey="G" style="margin-right: 4em;" type="submit" name="opcio" value="Guarda" />
            <input accesskey="C" type="button" name="opcio" value="Cancela" onclick="window.location='<?php echo $_SESSION['ultim_llistat'];?>' "; />
         </div>
         
   </form>
<?php
   }
?>
</body>
</html>