<?php
include 'header.php';
include 'erpc_transportadora_toolbar.php';
?>

<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
  <li role="presentation" class="active">
                          <a href="#form1" aria-controls="form1" role="tab" data-toggle="tab">Cadastro</a></li>
  <li role="presentation"><a href="#form2" aria-controls="form2" role="tab" data-toggle="tab">Adm/Fin.</a></li>
</ul>


<!-- Tab panes -->
<form id=validate_custom method=POST action="erpc_transportadora_ws.php">

<div class="tab-content">
  <!--<form id=validate_custom method=POST action="erpc_produto_ws.php" >-->

  <!--  aba de dados cadastrais -->
  <div role="tabpanel" class="tab-pane fade in active" id="form1">
    <div class="block">
        <div class="content controls">
          <div class="form-row">
            <div class="col-md-2"><label>Código</label></div>
            <div class="col-md-2"><input type=number name="ds_codigo" id="ds_codigo" class="validate[required] form-control" maxlength="04" size=4/></div>
            <div class="col-md-1"><label>Status</label></div>
            <div class="col-md-1">
              <div class="checked inline"><label> <input type=radio class=validate[required] name=st_acao value="1"/> Ativo</label></div>
            </div>
            <div class="col-md-1">
              <div class="checked inline"><label> <input type=radio class=validate[required] name=st_acao value="0"/> Bloqueado </label></div>
            </div>
          </div>

          <div class="form-row">
            <div class="col-md-2"><label>Empresa</label></div>
            <div class="col-md-10"><input name="ds_empresa" id="ds_empresa" class="validate[required] form-control nocharespecial" maxlength="60"/></div>
          </div>

          <div class="form-row">
            <div class="col-md-2"><label>Razão Social</label></div>
            <div class="col-md-10"><input name="ds_razao" id="ds_razao" class="validate[required] form-control nocharespecial" maxlength="60"/></div>
          </div>

          <div class="form-row">
            <div class="col-md-2"><label>Nome Fantasia</label></div>
            <div class="col-md-6"><input name="ds_fantasia" id="ds_fantasia" class="validate[required] form-control nocharespecial" maxlength="60"/></div>
          </div>

          <div class="form-row">
            <div class="col-md-2"><label>CEP</label></div>
            <div class="col-md-2">
              <div class="input-group">
                <input name="ds_cep" id="ds_cep" maxlenght="8" size="4" class="mask_cep">
                <div class="input-group-addon">
                <a href="helper-cep.php" class='input-helper' data-remote="false" data-toggle="modal" data-target="#helper-modal-div" data-value="#ds_cep" data-description="#ds_endereco" data-title="Selecione:">
                <span class="fa fa-search"></span></a>
              </div>
              </div>
            </div>
          </div>

          <div class="form-row">
            <div class="col-md-2"><label>Endereço</label></div>
            <div class="col-md-10"><input name="ds_endereco" id="ds_endereco" class="validate[required] form-control" maxlength="100"/></div>
          </div>

          <div class="form-row">
            <div class="col-md-2"><label>Complemento</label></div>
            <div class="col-md-6"><input name="ds_complemento" id="ds_complemento" maxlength="100"/></div>
          </div>

          <div class="form-row">
            <div class="col-md-2"><label>Bairro</label></div>
            <div class="col-md-4"><input name="ds_bairro" id="ds_bairro" class="validate[required] form-control" maxlength="60"/></div>
          </div>

		

          <!-- div class="form-row">
            <div class="col-md-2"><label>UF</label></div>
            <div class="col-md-2">
                <div class="input-group">
                <input name="ds_uf" id="ds_uf" class="validate[required] form-control" maxlength="2"/>
                <div class="input-group-addon">
                  <a href="helper-descricao-uf.php" class='input-helper' data-remote="false" data-toggle="modal" data-target="#helper-modal-div" data-value="#ds_uf" data-description="#ds_estado" data-title="Selecione:">
                  <span class="fa fa-search"></span></a>
                </div>
                </div>
            </div>
                <div class="col-md-2"><input name="ds_estado" id="ds_estado" readonly/></div>
          </div-->

        <div class="form-row">
          <div class="col-md-2"><label>Municípios</label></div>
          <div class="col-md-2">
            <div class="input-group">
              <input required id="id_municipio" name="id_municipio" value="<?=$id_municipio; ?>" />
              <div class="input-group-addon">
                <a href="erpc_municipios_helper.php" class='input-helper' data-remote="false" data-toggle="modal" data-target="#helper-modal-div" data-value="input[name='id_municipio']" data-description="input[name='ds_municipio']" data-title="Selecione:" value="<?=$id_municipio;?>">
                <span class="fa fa-search"></span></a>
              </div>
            </div>
          </div>
          <div class="col-md-3"><input readonly name="ds_municipio" id="ds_municipio"/></div>
          <div class="col-md-1"><input name="ds_uf" id="ds_uf" class="validate[required] form-control" maxlength="2"/></div>
        </div>

        <div class="form-row">
          <div class="col-md-2"><label>Pais</label></div>
          <div class="col-md-2">
            <div class="input-group">
            <input type=number name="id_pais" id="id_pais"/>
            <div class="input-group-addon">
              <a href="helper-paises-bacen.php" class='input-helper' data-remote="false" data-toggle="modal" data-target="#helper-modal-div" data-value="#id_pais" data-description="#ds_pais" data-title="Selecione:">
              <span class="fa fa-search"></span></a>
            </div>
            </div>
          </div>
          <div class="col-md-2"><input name="ds_pais" id="ds_pais" readonly/></div>
        </div>


        <div class="form-row">
          <div class="col-md-2"><label>Cx.Postal</label></div>
          <div class="col-md-1"><input type=number name="ds_cx_postal" id="ds_cx_postal"/></div>
          <div class="col-md-3">&nbsp;</div>
          <div class="col-md-1"><label>Tipo</label></div>
          <div class="col-md-2">
                  <select name="tp_tipo" id="tp_tipo">
                    <option value="F">F - Fisico</option>
                    <option value="J">J - Juridico</option>
                    <option value="X">X - Outros</option>
                  </select>
          </div>
        </div>

        <div class="form-row">
          <div class="col-md-2"><label>CNPJ</label></div>
          <div class="col-md-4"><input name="ds_cpf_cnpj" id="ds_cpf_cnpj" class="mask_cnpj"/></div>

          <div class="col-md-1"><label>RG</label></div>
          <div class="col-md-4"><input type=number name="ds_rg" id="ds_rg"></div>
        </div>

        <div class="form-row">
          <div class="col-md-2"><label>DDI</label></div>
          <div class="col-md-1"><input type=number name="ds_ddi" id="ds_ddi" maxlength="02"></div>
          <div class="col-md-2"><label>DDD</label></div>
          <div class="col-md-1"><input type=number name="ds_ddd" id="ds_ddd" maxlength="02"></div>
        </div>

        <div class="form-row">
          <div class="col-md-2"><label>Telefone</label></div>
          <div class="col-md-2"><input type=number name="ds_telefone" id="ds_telefone" maxlength="09" class="mask_nr_tel"></div>

          <div class="col-md-2">&nbsp;</div>
          <div class="col-md-2"><label>Fax</label></div>
          <div class="col-md-2"><input name="ds_fax" id="ds_fax" class="mask_nr_tel"/></div>
        </div>

        <div class="form-row">
          <div class="col-md-2"><label>Insc. Estadual</label></div>
          <div class="col-md-3"><input type=text name="ds_ie" id="ds_ie"/></div>

          <div class="col-md-1">&nbsp;</div>
          <div class="col-md-2"><label>Insc. Municipal</label></div>
          <div class="col-md-3"><input type=number name="ds_im" id="ds_im"/></div>
         </div>

         <div class="form-row">
           <div class="col-md-2"><label>E-mail</label></div>
           <div class="col-md-3"><input name="ds_email" id="ds_email" maxlength="40"/></div>

           <div class="col-md-1">&nbsp;</div>
           <div class="col-md-2"><label>Departamento</label></div>
           <div class="col-md-3"><input name="ds_departamento" id="ds_departamento" maxlength="40"/></div>
         </div>

        <div class="form-row">
          <div class="col-md-2"><label>Home Page</label></div>
          <div class="col-md-3"><input name="ds_homepage" id="ds_homepage" maxlength="100"/></div>

          <div class="col-md-1">&nbsp;</div>
          <div class="col-md-2"><label>Nr.Telex</label></div>
          <div class="col-md-1"><input type=number name="ds_telex" id="ds_telex" maxlength="20"/></div>
        </div>

        <div class="form-row">
          <div class="col-md-2"><label>CBO</label></div>
          <div class="col-md-1"><input type=number name="id_cbo" id="id_cbo"/></div>

          <div class="col-md-1">&nbsp;</div>
          <div class="col-md-2"><label>CNAE</label></div>
          <div class="col-md-1"><input type=number name="id_cnae" id="id_cnae"/></div>
        </div>

        <div class="form-row">
          <div class="col-md-2"><label>Observações</label></div>
          <div class="col-md-1"><input name="ds_observacao" id="ds_observacao" maxlength="255"/></div>
        </div>

    </div>
    </div>
  </div> <!-- fim da seção abas cadastrais -->

  <!--  adm fin aba -->
  <div role="tabpanel" class  ="tab-pane fade" id="form2">
    <div class="block">
       <div class="content controls">
          <div class="form-row" id="form2">
            <div class="col-md-2"><label>Banco</label></div>
            <div class="col-md-2">
              <div class="input-group">
              <input name="id_banco" id="id_banco" type="number" min="0" />
              <div class="input-group-addon">
                <a href="helper-bancos.php" class='input-helper' data-remote="false" data-toggle="modal" data-target="#helper-modal-div" data-value="#id_banco" data-description="#ds_banco" data-title="Selecione:">
                <span class="fa fa-search"></span></a>
               </div>
               </div>
               </div>
            <div class="col-md-4"><input name="ds_banco" id="ds_banco"/></div>
          </div>

          <div class="form-row">
            <div class="col-md-2"><label>Agência</label></div>
            <div class="col-md-1"><input name="nr_agencia" id="nr_agencia" type="number" min="0"/></div>
            <div class="col-md-1">&nbsp;</div>
            <div class="col-md-1"><label>Conta</label></div>
            <div class="col-md-2"><input name="ds_conta_corrente" id="ds_conta_corrente" type="number" min="0"/></div>
            <div class="col-md-1">&nbsp;</div>
          </div>

          <div class="form-row">
            <div class="col-md-2"><label>Natureza</label></div>
            <div class="col-md-2">
              <div class="input-group">
                <input name="ds_natureza" id="ds_natureza" type="number" min="0"/>
                <div class="input-group-addon">
                <a href="helper-plano-contas.php" class='input-helper' data-remote="false" data-toggle="modal" data-target="#helper-modal-div" data-value="#ds_natureza" data-description="#ds_natureza" data-title="Selecione:">
                <span class="fa fa-search"></span></a><br>
                </div>
                </div>
            </div>
            <div class="col-md-2"><input name="ds_natureza" id="ds_natureza" readonly/></div>
          </div>

            <div class="form-row">
            <div class="col-md-2"><label>Cond.Pagto</label></div>
            <div class="col-md-2">
              <div class="input-group">
              <input name="id_condicao_pagamento" id="id_condicao_pagamento"/>
                <div class="input-group-addon">
                <a href="helper-plano-condicao.php" class='input-helper' data-remote="false" data-toggle="modal" data-target="#helper-modal-div" data-value="#id_condicao_pagamento" data-description="#ds_pagto" data-title="Selecione:">
                <span class="fa fa-search"></span></a>
                </div>
              </div>
            </div>
            <div class="col-md-2"><input name="ds_pagto" id="ds_pagto" readonly/></div>
            </div>


        <div class="row clear">&nbsp;</div>
        <div class="content controls">
          <div class="form-row">
            <div class="col-md-2"><label>Maior Frete</label></div>
            <div class="col-md-2"><input name="vl_maior_frete" id="vl_maior_frete" type="number" value="0.00" min="0" step="0.00" readonly/></div>
            <div class="col-md-1">&nbsp;</div>
            <div class="col-md-2"><label>Média Atraso</label></div>
            <div class="col-md-2"><input name="nr_media_atraso" id="nr_media_atraso" type="number" value="0.00" min="0" step="0.00" readonly/></div>
          </div>
          <div class="form-row">
            <div class="col-md-2"><label>Maior Saldo</label></div>
            <div class="col-md-2"><input name="vl_maior_saldo" id="vl_maior_saldo" type="number"  value="0.00" min="0" step="0.00" readonly/></div>
            <div class="col-md-1">&nbsp;</div>
            <div class="col-md-2"><label>N.° Entregas</label></div>
            <div class="col-md-1"> <input name="nr_entregas" id="nr_entregas" type="number"  value="0.00" min="0" step="0" readonly/></div>
          </div>

          <div class="form-row">
            <div class="col-md-2"><label>Saldo Duplicatas</label></div>
            <div class="col-md-2"><input name="vl_saldo_duplicatas" id="vl_saldo_duplicatas" type="number"  value="0.00" min="0" step="0.00" readonly/></div>
          </div>


        </div>
      </div>
    </div>

  </div> <!-- fim da tab bancos adm /fin -->

  <div class=footer>
      <div class="side pull-right">
        <div class=btn-group>
          <button class="btn btn-default" type="button" onClick="window.history.go(-1)" value="Voltar">Voltar</button>
          <button class="btn btn-success" type="submit" value="adicionar" onClick="$('#validate_custom').validationEngine('hide');" name="adicionar">Adicionar</button>
        </div>
      </div>
    </div>


</div>

</form>

<!-- modal do helper -->
<div class="row-clear">&nbsp;</div>
<div class="modal modal-white modal-draggable fade" id="helper-modal-div" tabindex="-1" role="dialog" aria-labelledby="helper-modal-label" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="helper-modal-label">Helper</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal" id="modalCancel">Cancelar</button>
        <button type="button" class="btn btn-primary" data-dismiss="modal" id="modalOk" disabled="disabled">Selecionar</button>
      </div>
    </div>
  </div>
</div>


<?php include 'footer.php'; ?>
<script type="text/javascript" src="js/acme.js"></script>
<script type="text/javascript" src="js/caracteres.js"></script>

<script type="text/javascript"> 
$("input[name='id_municipio']").blur(function(){

	var id_municipio = $("input[name='id_municipio']").val();

	$.post("erpc_consulta_uf.php", {
		key: id_municipio
		}
		, function(data, status){
        	//alert("Data: " + data + "\nStatus: " + status);
        	$("#ds_uf").val(data);
    	}
    );
});

</script>
<script type="text/javascript" >

    $("[name='ds_ie']").keyup(function(){
    	$(this).val($(this).val().replace(".", ""));
    });
    $("[name='ds_ie'").blur(function(){
    	$(this).val($(this).val().replace(".", ""));
    });
    
</script>
