<?
   session_start();
   if (!isset($_SESSION['cod_rentacar']))
      header("location: login.php");
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Dados Gerais</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<META NAME="Generator" CONTENT="NetObjects Fusion 8 for Windows">
<link rel="stylesheet" href="../assets/clases.css" type="text/css" />
<script language="javascript" src="../assets/help_functions.js"></script>
<SCRIPT>
<!--
var F_A,F_B,F_CH,F_CL,F_DB,F_E,F_F,F_L,F_MT,F_MV,F_R,F_SE,F_SU,F_U,F_HR,F_MU,F_MD;
function F_e(){} function F_n(){} function F_onLoaded(){}
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2">
<!--
document.write("<SCRIPT SRC=\"../assets/script.js\"><\/SCRIPT>");
document.write("<SCRIPT SRC=\"../assets/effects.js\"><\/SCRIPT>");
//-->
</SCRIPT>
<SCRIPT>
<!--
function F_doLoaded() {
	document.main = new F_cMain();
	document.objectModel = new Object();
	F_OM('Layout','LayoutLYR', 'doc', '', new Array());
	F_OM('ID_btBack' , '', 'btn', 'Layout',new Array(
	'Clicked',F_functID_btBackAction0,'','',0),'LayoutRegion3FORM',0,'btBack');
	F_pageLoaded('Layout');
}
function F_functID_btBackAction0(params) {
history.back();
}

//-->
</SCRIPT>
<LINK REL=STYLESHEET TYPE="text/css" HREF="../html/style.css">
<LINK REL=STYLESHEET TYPE="text/css" HREF="../html/site.css">
<STYLE>
</STYLE><NOLAYER>
<STYLE ID="NOF_STYLE_SHEET">
<!--
DIV#LayoutLYR { position:relative; top:0; left:0; z-index: 1; visibility:inherit; }
-->
</STYLE>

</NOLAYER>
</HEAD>
<BODY NOF="(MB=(save, 213, 65, 0, 0), L=(dadosgerais2Layout, 760, 310))" STYLE="text-align: center;" onLoad="F_onLoaded();">
    <DIV ID="LayoutLYR"><LAYER ID="LayoutLYR" TOP=0 LEFT=0 VISIBILITY=INHERIT WIDTH=760 HEIGHT=588 Z-INDEX=1>
    <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 NOF=LY>
        <TR VALIGN=TOP ALIGN=LEFT>
            <TD WIDTH=760>
                <TABLE ID="Table1" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%" HEIGHT=213>
                    <TR HEIGHT=41>
                        <TD WIDTH=760 STYLE="background-color: rgb(255,255,255); background-image: none;">
                            <P>
                                <TABLE WIDTH=760 BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=LEFT NOF=TE>
                                    <TR>
                                        <TD>
                                            <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=760 HEIGHT=41 NOF="LayoutRegion1">
                                                <TR ALIGN=LEFT VALIGN=TOP>
                                                    <TD>
                                                        <TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0 WIDTH=735 NOF="LayoutRegion1">
                                                            <TR VALIGN=TOP ALIGN=LEFT>
                                                                <TD>
                                                                    <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=425 NOF="LayoutRegion1">
                                                                        <TR VALIGN=TOP ALIGN=LEFT>
                                                                            <TD WIDTH=409 HEIGHT=16><IMG SRC="../assets/images/autogen/clearpixel.gif" WIDTH=409 HEIGHT=1 BORDER=0 ALT=""></TD>
                                                                            <TD></TD>
                                                                        </TR>
                                                                        <TR VALIGN=TOP ALIGN=LEFT>
                                                                            <TD HEIGHT=15></TD>
                                                                            <TD WIDTH=16><IMG ID="Picture2" HEIGHT=15 WIDTH=16 SRC="../assets/images/ihhomicon1.jpg" BORDER=0 ALT="ihhomicon" TITLE="ihhomicon"></TD>
                                                                        </TR>
                                                                    </TABLE>
                                                                </TD>
                                                                <TD>
                                                                    <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=56 NOF="LayoutRegion1">
                                                                        <TR VALIGN=TOP ALIGN=LEFT>
                                                                            <TD WIDTH=2 HEIGHT=17><IMG SRC="../assets/images/autogen/clearpixel.gif" WIDTH=2 HEIGHT=1 BORDER=0 ALT=""></TD>
                                                                            <TD WIDTH=54><IMG SRC="../assets/images/autogen/clearpixel.gif" WIDTH=54 HEIGHT=1 BORDER=0 ALT=""></TD>
                                                                        </TR>
                                                                        <TR VALIGN=TOP ALIGN=LEFT>
                                                                            <TD></TD>
                                                                            <TD WIDTH=54 CLASS="TextObject">
                                                                                <P><B><U><SPAN STYLE="font-size: 10px;">Home</SPAN></U></B></P>
                                                                            </TD>
                                                                        </TR>
                                                                    </TABLE>
                                                                </TD>
                                                                <TD>
                                                                    <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=21 NOF="LayoutRegion1">
                                                                        <TR VALIGN=TOP ALIGN=LEFT>
                                                                            <TD WIDTH=5 HEIGHT=16><IMG SRC="../assets/images/autogen/clearpixel.gif" WIDTH=5 HEIGHT=1 BORDER=0 ALT=""></TD>
                                                                            <TD></TD>
                                                                        </TR>
                                                                        <TR VALIGN=TOP ALIGN=LEFT>
                                                                            <TD HEIGHT=15></TD>
                                                                            <TD WIDTH=16><IMG ID="Picture3" HEIGHT=15 WIDTH=16 SRC="../assets/images/ihemail1.jpg" BORDER=0 ALT="ihemail" TITLE="ihemail"></TD>
                                                                        </TR>
                                                                    </TABLE>
                                                                </TD>
                                                                <TD>
                                                                    <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=84 NOF="LayoutRegion1">
                                                                        <TR VALIGN=TOP ALIGN=LEFT>
                                                                            <TD WIDTH=2 HEIGHT=17><IMG SRC="../assets/images/autogen/clearpixel.gif" WIDTH=2 HEIGHT=1 BORDER=0 ALT=""></TD>
                                                                            <TD WIDTH=82><IMG SRC="../assets/images/autogen/clearpixel.gif" WIDTH=82 HEIGHT=1 BORDER=0 ALT=""></TD>
                                                                        </TR>
                                                                        <TR VALIGN=TOP ALIGN=LEFT>
                                                                            <TD></TD>
                                                                            <TD WIDTH=82 CLASS="TextObject">
                                                                                <P><B><U><SPAN STYLE="font-size: 10px;">Contacte-nos</SPAN></U></B></P>
                                                                            </TD>
                                                                        </TR>
                                                                    </TABLE>
                                                                </TD>
                                                                <TD>
                                                                    <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=24 NOF="LayoutRegion1">
                                                                        <TR VALIGN=TOP ALIGN=LEFT>
                                                                            <TD WIDTH=7 HEIGHT=15><IMG SRC="../assets/images/autogen/clearpixel.gif" WIDTH=7 HEIGHT=1 BORDER=0 ALT=""></TD>
                                                                            <TD></TD>
                                                                        </TR>
                                                                        <TR VALIGN=TOP ALIGN=LEFT>
                                                                            <TD HEIGHT=17></TD>
                                                                            <TD WIDTH=17><IMG ID="Picture7" HEIGHT=17 WIDTH=17 SRC="../assets/images/ihgobutton031.jpg" BORDER=0 ALT="ihgobutton03" TITLE="ihgobutton03"></TD>
                                                                        </TR>
                                                                    </TABLE>
                                                                </TD>
                                                                <TD>
                                                                    <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=44 NOF="LayoutRegion1">
                                                                        <TR VALIGN=TOP ALIGN=LEFT>
                                                                            <TD WIDTH=6 HEIGHT=17><IMG SRC="../assets/images/autogen/clearpixel.gif" WIDTH=6 HEIGHT=1 BORDER=0 ALT=""></TD>
                                                                            <TD WIDTH=38><IMG SRC="../assets/images/autogen/clearpixel.gif" WIDTH=38 HEIGHT=1 BORDER=0 ALT=""></TD>
                                                                        </TR>
                                                                        <TR VALIGN=TOP ALIGN=LEFT>
                                                                            <TD></TD>
                                                                            <TD WIDTH=38 CLASS="TextObject">
                                                                                <P><B><U><SPAN STYLE="color: rgb(255,102,0);">Ajuda</SPAN></U></B></P>
                                                                            </TD>
                                                                        </TR>
                                                                    </TABLE>
                                                                </TD>
                                                                <TD>
                                                                    <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=29 NOF="LayoutRegion1">
                                                                        <TR VALIGN=TOP ALIGN=LEFT>
                                                                            <TD WIDTH=22 HEIGHT=21><IMG SRC="../assets/images/autogen/clearpixel.gif" WIDTH=22 HEIGHT=1 BORDER=0 ALT=""></TD>
                                                                            <TD></TD>
                                                                        </TR>
                                                                        <TR VALIGN=TOP ALIGN=LEFT>
                                                                            <TD HEIGHT=5></TD>
                                                                            <TD WIDTH=7><IMG ID="Picture8" HEIGHT=5 WIDTH=7 SRC="../assets/images/ihbullet.jpg" BORDER=0 ALT="ihbullet" TITLE="ihbullet"></TD>
                                                                        </TR>
                                                                    </TABLE>
                                                                </TD>
                                                                <TD>
                                                                    <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=52 NOF="LayoutRegion1">
                                                                        <TR VALIGN=TOP ALIGN=LEFT>
                                                                            <TD WIDTH=3 HEIGHT=17><IMG SRC="../assets/images/autogen/clearpixel.gif" WIDTH=3 HEIGHT=1 BORDER=0 ALT=""></TD>
                                                                            <TD WIDTH=49><IMG SRC="../assets/images/autogen/clearpixel.gif" WIDTH=49 HEIGHT=1 BORDER=0 ALT=""></TD>
                                                                        </TR>
                                                                        <TR VALIGN=TOP ALIGN=LEFT>
                                                                            <TD></TD>
                                                                            <TD WIDTH=49 CLASS="TextObject">
                                                                                <P><B><SPAN STYLE="font-size: 10px;" class="link_azul"><A HREF="./logout.php">Sair</A></SPAN></B>&nbsp;</P>
                                                                            </TD>
                                                                        </TR>
                                                                    </TABLE>
                                                                </TD>
                                                            </TR>
                                                        </TABLE>
                                                    </TD>
                                                </TR>
                                            </TABLE>
                                        </TD>
                                    </TR>
                                </TABLE>
                            </P>
                        </TD>
                    </TR>
                    <TR HEIGHT=137>
                        <TD>
                            <P><IMG ID="Banner2" HEIGHT=137 WIDTH=760 SRC="../assets/images/autogen/Dados_Gerais_NDefault.jpg" VSPACE=0 HSPACE=0 ALIGN="TOP" BORDER=0 ALT="Dados Gerais" TITLE="Dados Gerais" NOF=B_H></P>
                        </TD>
                    </TR>
                    <TR HEIGHT=34>
                        <TD STYLE="background-color: rgb(255,255,255); background-image: url('../assets/images/ihnavbg1.jpg');">
                            <H1 STYLE="text-align: center;"><SPAN STYLE="font-size: x-small; font-weight: normal;"></SPAN></TD>
                    </TR>
                    <TR HEIGHT=1>
                        <TD STYLE="background-color: rgb(255,255,255); background-image: url('../assets/images/ihtop31.gif');">
                            <P></P>
                        </TD>
                    </TR>
                </TABLE>
            </TD>
        </TR>
    </TABLE>
    <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=760 NOF=LY>
        <TR VALIGN=TOP ALIGN=LEFT>
            <TD HEIGHT=310 WIDTH=760>
                <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=760 HEIGHT=310 STYLE="background-color: rgb(237,237,237);" NOF="LayoutRegion3">
                    <TR ALIGN=LEFT VALIGN=TOP>
                        <TD>
                            <FORM NAME="LayoutRegion3FORM" ACTION="" METHOD=POST>
                                <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=704 NOF="LayoutRegion3">
                                    <TR VALIGN=TOP ALIGN=LEFT>
                                        <TD WIDTH=98 HEIGHT=18><IMG SRC="../assets/images/autogen/clearpixel.gif" WIDTH=98 HEIGHT=1 BORDER=0 ALT=""></TD>
                                        <TD WIDTH=606><IMG SRC="../assets/images/autogen/clearpixel.gif" WIDTH=606 HEIGHT=1 BORDER=0 ALT=""></TD>
                                    </TR>
                                    <TR VALIGN=TOP ALIGN=LEFT>
                                        <TD></TD>
                                        <TD WIDTH=606 CLASS="TextObject">
                                            <P><?
	include('main.php');
       include('../assets/ftpfunc.php');

	db_connect();

	if ($_SERVER['REQUEST_METHOD'] == "POST") 
       {
          $nomecomercial   = $_POST['NomeComercial'];
          $nomenegocio     = $_POST['NomeNegocio'];
          $contribuinte    = $_POST['Contribuinte'];
          $morada          = $_POST['Morada'];
          $cidade          = $_POST['Cidade'];
          $codigopostal    = $_POST['CodigoPostal'];
          $telefone        = $_POST['Telefone'];
          $telemovel       = $_POST['Telemovel'];
          $pais            = $_POST['Pais'];
          $regiaoturistica = $_POST['RegiaoTuristica'];
          $fax             = $_POST['Fax'];
          $email           = $_POST['Email'];
          $website         = $_POST['Website'];
          $tel_reserva     = $_POST['TelefoneReserva'];
          $email_reserva   = $_POST['EmailReserva'];
         
          $data_alteracao = date("Y/m/d H:i:s");

          $sql = "update tr_rentacar set nomecomercial='$nomecomercial', nome='$nomenegocio', ";
          $sql = $sql."contribuinte='$contribuinte', ";
          $sql = $sql."morada='$morada', cidade='$cidade', ";
          $sql = $sql."cod_postal='$codigopostal', telefone='$telefone', telemovel='$telemovel', ";
          $sql = $sql."cod_pais='$pais', cod_regiao=$regiaoturistica, "; 
          $sql = $sql."fax='$fax', email='$email', website='$website', "; 
          $sql = $sql."telefone_reserva='$tel_reserva', email_reserva='$email_reserva', "; 
          $sql = $sql."data_alteracao='$data_alteracao' "; 
          $sql = $sql."where cod_rentacar = ".$_SESSION['cod_rentacar'];
          
          $result = mysql_query($sql) or die("update fails");

          if (isset($result)) 
          {
             $Actualiza = 1;
             $mensagem = '<B><SPAN STYLE="font-family: Verdana,Tahoma,Arial,Helvetica,Sans-serif; font-size: xx-small;">Obrigada. Seus dados gerais foram actualizados com sucesso!</SPAN></B><BR>';             
	   } 
          else 
          {
             $Actualiza = 0;
             $mensagem = '<B><SPAN STYLE="font-family: Verdana,Tahoma,Arial,Helvetica,Sans-serif; font-size: xx-small;">Ocorreu um erro actualizando os dados. Por favor contactar a Bravacar</SPAN></B><BR>';             
	   }
          
          $mensagem1 = '';
          if ($Actualiza == 1)
          {
              $nome_contacto  = $_POST['NomeContacto'];
              $email_contacto = $_POST['EmailContacto'];   
              $telf_contacto  = $_POST['TelefoneContacto'];
              $telm_contacto  = $_POST['TelemovelContacto'];
              $fax_contacto   = $_POST['FaxContacto'];
                     
              $sql = "update tbcontactos set nome_contacto='$nome_contacto',";
              $sql = $sql." email_contacto='$email_contacto',";
              $sql = $sql." telefone_contacto='$telf_contacto',";
              $sql = $sql." telemovel_contacto='$telm_contacto',";
              $sql = $sql." fax_contacto='$fax_contacto'"; 
              $sql = $sql." where cod_empresa = ".$_SESSION['cod_rentacar'];
              $sql = $sql." and tipo_empresa = 2";
          
              $result = mysql_query($sql) or die("update fails");
   
              if (!isset($result))                 
              {           
                 $mensagem1 = '<P STYLE="text-align: justify;"><B><SPAN STYLE="font-family: Verdana,Tahoma,Arial,Helvetica,Sans-serif; font-size: xx-small;">Ocorreu um erro actualizando os dados do contacto. Por favor contactar a Bravacar.pt</SPAN></B></P>';       
                 $Actualiza = 0;      
	       }    
          }

          $mensagem2 = '';
          if ($Actualiza==1 and $_FILES['path_logo']['name'] !="" and !(isset($_POST['del_logo'])))
          {       
             $filesize = filesize($_FILES['path_logo']['tmp_name']); 
             if ($filesize >= 51200)
             { 
                 $mensagem2 = "<B><SPAN STYLE='font-family: 

Verdana,Tahoma,Arial,Helvetica,Sans-serif; font-size: xx-small;'>O tamanho da imagem ".$_FILES['path_logo']['name']." é 

".$filesize." bytes.<br>O tamanho do logo é muito grande.<br>Deve de ser menor a 50KB ou 51200 bytes</SPAN></B><BR>";
             }
             else
             { 
                 $logo = $_FILES['path_logo']['name'];    
                 SubirArquivo($_POST["pasta"],$_FILES['path_logo']['tmp_name'],$logo);     

                 $sql = "update tr_rentacar set ";
                 $sql = $sql." logotipo ='$logo' ";
                 $sql = $sql." where cod_rentacar = ".$_SESSION['cod_rentacar'];
                            
                 $result1 = mysql_query($sql);               
                 if ($result1=='')
                     $mensagem2="<B><SPAN STYLE='font-family:  Verdana,Tahoma,Arial,Helvetica,Sans-serif; font-size: xx-small;'>Ocorreu um erro na inserção do logo</SPAN></B><BR>";                  
                 else
                     $mensagem2="<B><SPAN STYLE='font-family:  Verdana,Tahoma,Arial,Helvetica,Sans-serif; font-size: xx-small;'>A inserção do logo foi efectuada com sucesso</SPAN></B><BR>";   
             } 
          }

          $mensagem3 = '';
          if (isset($_POST['del_logo']) and $_POST['logotipo']!='')
          {           
             ApagarArquivo($_POST['pasta'],$_POST['logotipo']); 
             $sql = "update tr_rentacar set logotipo = '' ";
             $sql = $sql." where cod_rentacar = ".$_SESSION['cod_rentacar'];
          
             $result2 = mysql_query($sql);
             if ($result2=='')
                $mensagem3="<B><SPAN STYLE='font-family:  Verdana,Tahoma,Arial,Helvetica,Sans-serif; font-size: xx-small;'>Ocorreu um erro eliminando o logo</SPAN></B><BR>";                  
             else
                $mensagem3="<B><SPAN STYLE='font-family:  Verdana,Tahoma,Arial,Helvetica,Sans-serif; font-size: xx-small;'>O logo foi eliminado com sucesso</SPAN></B><BR>";
          } 

          echo $mensagem.$mensagem1.$mensagem2.$mensagem3;
       }
	db_disconnect();
?>
&nbsp;</P>
                                        </TD>
                                    </TR>
                                </TABLE>
                                <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 NOF="LayoutRegion3">
                                    <TR VALIGN=TOP ALIGN=LEFT>
                                        <TD WIDTH=98 HEIGHT=10><IMG SRC="../assets/images/autogen/clearpixel.gif" WIDTH=98 HEIGHT=1 BORDER=0 ALT=""></TD>
                                        <TD></TD>
                                    </TR>
                                    <TR VALIGN=TOP ALIGN=LEFT>
                                        <TD></TD>
                                        <TD WIDTH=99>
                                            <TABLE ID="Table5" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%" HEIGHT=31>
                                                <TR>
                                                    <TD>
                                                        <P><INPUT TYPE=BUTTON NAME="btBack" VALUE="Voltar" ID="ID_btBack" class="text_objects" onClick="return(F_e('ID_btBack', F_CL))"></P>
                                                    </TD>
                                                </TR>
                                            </TABLE>
                                        </TD>
                                    </TR>
                                </TABLE>
                            </FORM>
                        </TD>
                    </TR>
                </TABLE>
            </TD>
        </TR>
        <TR VALIGN=TOP ALIGN=LEFT>
            <TD HEIGHT=65 WIDTH=760>
                <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=760 HEIGHT=65 STYLE="background-color: rgb(0,51,102);" NOF="LayoutRegion6">
                    <TR ALIGN=LEFT VALIGN=TOP>
                        <TD>
                            <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=564 NOF="LayoutRegion6">
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD WIDTH=212 HEIGHT=28><IMG SRC="../assets/images/autogen/clearpixel.gif" WIDTH=212 HEIGHT=1 BORDER=0 ALT=""></TD>
                                    <TD WIDTH=352><IMG SRC="../assets/images/autogen/clearpixel.gif" WIDTH=352 HEIGHT=1 BORDER=0 ALT=""></TD>
                                </TR>
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD></TD>
                                    <TD WIDTH=352 CLASS="TextObject">
                                        <P STYLE="text-align: center;"><B><SPAN STYLE="color: rgb(255,255,255);">Copyright Bravacar 2006</SPAN></B></P>
                                    </TD>
                                </TR>
                            </TABLE>
                        </TD>
                    </TR>
                </TABLE>
            </TD>
        </TR>
    </TABLE>
    </LAYER></DIV>
</BODY>
</HTML>
 