<cfscript>
	// Abre conexo
	 conn_ct_consult = CreateComponent("_com.consulta.cfc_contrato_transporte");
	 conn_emissao_consult = CreateComponent("_com.consulta.cfc_emissao_documentos");
	 conn_pessoas_consult = CreateComponent("_com.consulta.cfc_pessoas");
	 // Busca sries
 	 qrSerie = conn_emissao_consult.get_serie();
	 try {
		 if (isDefined("vars.NUM_CONHECIMENTO")) {
			qrConhecimento       = conn_ct_consult.get_conhecimento_sem_ct(num_conhecimento = vars.NUM_CONHECIMENTO, serie = vars.SERIE);
			qrServico_Contratado = conn_ct_consult.get_servico_contratado(p_placa=qrConhecimento.PLACA,p_data_emissao=DateFormat(qrConhecimento.DATA_EMISSAO,'dd/mm/yyyy'));
			qrPessoa 			 = conn_pessoas_consult.get_pessoa_fisica(cpf = vars.CPF_MOTORISTA);
			qrConhecimentos 	 = conn_ct_consult.get_conhecimento_sem_ct(num_romaneio = qrConhecimento.NUM_ROMANEIO);
		 }
		erro = false;
     }
	 catch ( Any e) 
	 {
		conexao_erro = CreateComponent("_com.manipulacao.cfc_erros");	  
		erro = true;
		session.erro = e;
		mensagem = conexao_erro.get_trata_erro(detalhe=e.getDetail(), numero_erro=e.getNativeErrorCode());
	 }
	</cfscript>
<cfif erro>
	<script language="javascript1.2">
		alert('<cfoutput>#JSStringFormat(mensagem)#</cfoutput>');		
	</script>	
</cfif>
<html>
<head>

<title>..: Del Pozo NET :..</title>
<script language="javascript1.2" src="../../../../scripts/scripts.js"></script>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">


<link href="../../../../estilos/padrao.css" rel="stylesheet" type="text/css" media="screen">
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td>      <table width="760" border="0" align="left" cellpadding="3" cellspacing="0" >
        <form name="form_conhecimento" method="post" action="">
          <tr>
            <td colspan="7" class="texto_negrito">Cadastrar Contrato de Transporte</td>
          </tr>
          <tr class="texto_negrito">
            <td width="60" nowrap>N&ordm; CTRC: </td>
            <td width="75" nowrap><input name="NUM_CONHECIMENTO" type="text" class="caixa_texto" id="NUM_CONHECIMENTO" size="15" maxlength="20" value="<cfif isDefined("vars.NUM_CONHECIMENTO")><cfoutput>#vars.NUM_CONHECIMENTO#</cfoutput></cfif>"></td>
            <td width="33" nowrap>S&eacute;rie:</td>
            <td width="30" nowrap><select name="SERIE" class="caixa_texto">
              <cfoutput query="qrSerie">
                <option value="#qrSerie.SERIE#">#qrSerie.SERIE#</option>
                </cfoutput>
            </select></td>
            <td width="96" nowrap>CPF Motorista: </td>
            <td nowrap><input name="CPF_MOTORISTA" style=" width:100" type="text" class="caixa_texto" id="CPF_MOTORISTA" size="13" maxlength="11" value="<cfif isDefined("vars.CPF_MOTORISTA")><cfoutput>#vars.CPF_MOTORISTA#</cfoutput></cfif>">
            <img src="../../../../imagens/botao/16x16/procurar.gif" align="absmiddle" alt="Procurar" width="16" height="16" border="0" class="botao-img" onClick="NewWindow('../consultas/busca_motorista.cfm','consulta_motorista','500','300','yes');return false"></td>
            <td width="261" nowrap><button class="botao" style="height:21px " type="submit"><img src="../../../../imagens/botao/16x16/visualizar.gif" width="16" height="16" align="absmiddle"> Buscar </button><button class="botao" style="height:21px " onClick="window.location='../../principal.cfm'"><img width="16" height="16" src="../../../../imagens/botao/16x16/voltar.gif" align="absmiddle"> Voltar</button></td>
          </tr>
        </form>
        <form name="form_contrato" method="post" action="form_contrato_servico.cfm" target="_self">
          <cfif isDefined("qrConhecimentos")>
            <tr class="texto_negrito">
              <td colspan="7">
                 <table width="100%"  border="0" cellspacing="0" cellpadding="3">
                   <tr>
                     <td height="23" colspan="4" class="texto_negrito">Romaneio:&nbsp;<cfoutput>#qrConhecimento.NUM_ROMANEIO#</cfoutput>
                       <cfoutput>
                         <input name="CPF_MOTORISTA" type="hidden" id="CPF_MOTORISTA" value="#vars.CPF_MOTORISTA#">
                         <input name="FRETE_UNITARIO" type="hidden" id="FRETE_UNITARIO" value="#qrConhecimento.FRETE_UNITARIO#">
                         <input name="FRETE_EM" type="hidden" id="NOME_MOTORISTA" value="#qrConhecimento.FRETE_EM#">
                         <input name="PESO_TOTAL" type="hidden" id="PESO_TOTAL"  value="#qrConhecimento.PESO#">
                         <input name="COD_UNIDADE" type="hidden" id="COD_PESSOA_MOTORISTA" value="#qrConhecimento.COD_UNIDADE#">
                         <input name="NOME_MOTORISTA" type="hidden" id="NOME_MOTORISTA" value="#JSStringFormat(qrPessoa.NOME)#">
                         <input name="COD_PESSOA_MOTORISTA" type="hidden" id="COD_PESSOA_MOTORISTA" value="#qrPessoa.COD_PESSOA#">
                         <input name="CNH_NUMERO" type="hidden" id="CNH_NUMERO" value="#qrPessoa.CNH_NUM_REGISTRO#">
                         <input name="CNH_VALIDADE" type="hidden" id="CNH_VALIDADE" value="#DateFormat(qrPessoa.CNH_VALIDADE,'dd/mm/yyyy')#">
                         <input name="PLACA_REFERENCIA" type="hidden" id="PLACA_REFERENCIA" value="#qrConhecimento.PLACA_REFERENCIA#">
                         <input name="PLACA_CONTROLE" type="hidden" id="PLACA_CONTROLE" value="#qrConhecimento.PLACA_CONTROLE#">
                         <input name="CNPJ_CPF_PROPRIETARIO" type="hidden" id="CNPJ_CPF_PROPRIETARIO" value="#qrServico_Contratado.CNPJ_PROP#">
                         <input name="COD_PESSOA_PROPRIETARIO" type="hidden" id="COD_PESSOA_PROPRIETARIO" value="#qrServico_Contratado.COD_PESSOA_PROPRIETARIO#">
                         <input name="PROPRIETARIO_COD_UF" type="hidden" id="PROPRIETARIO_COD_UF" value="#qrServico_Contratado.PROPRIETARIO_COD_UF#">
                         <input name="PROPRIETARIO_COD_MUNICIPIO" type="hidden" id="PROPRIETARIO_COD_MUNICIPIO" value="#qrServico_Contratado.PROPRIETARIO_COD_MUNICIPIO#">
                         <input name="PROPRIETARIO_COD_DISTRITO" type="hidden" id="PROPRIETARIO_COD_DISTRITO" value="#qrServico_Contratado.PROPRIETARIO_COD_DISTRITO#">
                         <input name="PROPRIETARIO_COD_DV" type="hidden" id="PROPRIETARIO_COD_DV" value="#qrServico_Contratado.PROPRIETARIO_COD_DV#">
                         <input name="PROPRIETARIO" type="hidden" id="PROPRIETARIO" value="#JSStringFormat(qrServico_Contratado.PROPRIETARIO)#">
                         <input name="ENDERECO_PROPRIETARIO" type="hidden" id="ENDERECO_PROPRIETARIO" value="#JSStringFormat(qrServico_Contratado.ENDERECO)#">
                         <input name="UF_PROPRIETARIO" type="hidden" id="UF_PROPRIETARIO" value="#qrServico_Contratado.UF#">
                         <input name="CIDADE" type="hidden" id="CIDADE" value="#JSStringFormat(qrServico_Contratado.CIDADE)#">
                         <input name="NIT_PROPRIETARIO" type="hidden" id="NIT_PROPRIETARIO" value="#qrServico_Contratado.PIS_PASEP_NIT#">                       </cfoutput>                     </td>
			       </tr>
                   <cfoutput>
                     <tr>
                       <td height="23" class="texto_negrito">Carregamento:</td>
				       <td height="23" class="texto">#qrConhecimento.CARREGAMENTO#</td>
				       <td height="23" class="texto_negrito">Destino:</td>
				       <td height="23" class="texto">#qrConhecimento.DESTINO#
				         <input name="NUM_ROMANEIO" type="hidden" id="NUM_ROMANEIO" value="#qrConhecimento.NUM_ROMANEIO#">
				         <input name="NUM_LOTE" type="hidden" id="NUM_LOTE" value="#qrConhecimento.NUM_LOTE#">			           </td>
				     </tr>
                   </cfoutput>
                   <tr>
                     <td height="23" colspan="4" class="texto_negrito">Conhecimento que pertencem ao romaneio </td>
				     </tr>
                   <cfoutput query="qrConhecimentos">
                     <tr class="texto">
                       <td width="12%" nowrap class="texto_negrito">Data emiss&atilde;o: </td>
				       <td width="26%">#DateFormat(qrConhecimentos.DATA_EMISSAO,'dd/mm/yyyy')#</td>
				       <td width="8%" class="texto_negrito">Placa:</td>
				       <td width="54%">#qrConhecimentos.PLACA#</td>
				     </tr>
                     <tr class="texto">
                       <td nowrap class="texto_negrito">Destinat&aacute;rio:</td>
				       <td>#qrConhecimentos.NOME_FANTASIA#</td>
				       <td class="texto_negrito">Munic&iacute;pio:</td>
				       <td>#qrConhecimentos.MUNICIPIO#</td>
				     </tr>
                   </cfoutput>
                   <tr class="texto">
                     <td colspan="4" nowrap class="texto_negrito"><div align="center">
                       <button class="botao" style="height:21px " onClick="window.location='../../principal.cfm'"><img src="../../../../imagens/botao/16x16/voltar.gif" align="absmiddle" width="16" height="16"> Voltar</button><button class="botao" style="width:220px " type="submit"><img src="../../../../imagens/botao/16x16/vincular.gif" width="16" height="16" align="absmiddle"> Vincular Contrato de Transporte</button>
					   </div></td>
				     </tr>
                  </table>		      </td>
		    </tr>
          </cfif>
        </form>
    </table></td>
  </tr>
</table>
</body>

<script language="javascript1.2">
function f_consulta_motorista() {
}
</script>
</html>