Ir para conteúdo
Fórum Script Brasil
  • 0

javscript


zangetsu

Pergunta

<?php 
   session_start();
   if (($_SESSION["usuario"] =="") and ($_SESSION["senha"] == "")):
      print "&lt;script> location.href=('login.php'); </script>";
   endif;
   require('includes/funcoes_php.php');
   include('db/connect.inc.php');
   $_SESSION['cliente']=$_GET['cliente'];
   $codigo_cliente = $_GET['cliente'];
   $cont   = $_POST['idh_pos'];
   $cod_excluir = $_POST['idh_pref_cod'.$cont];
   if($_POST['idh_delete']  == 'sim'): 
      if ($cod_excluir != ""):
         $sql = "DELETE FROM CLIENTES_REFERENCIA  
                       WHERE CLIENTE = $codigo_cliente 
                         AND CODIGO  = $cod_excluir";
         if($db->Execute($sql) == false):
            alerta('error delete: '.str_replace("\"","_",$db->ErrorMsg()).'');
            print $sql;
         endif;
      endif;
   endif;
   
   
   if ($_POST['btn_salvar'] == 'Salvar'):  
      if ($cont != ""):
         if ($_POST['edt_pref_renda'.$cont] == ""):
            $renda = 'null'; 
         else:
            $renda = "'".$_POST['edt_pref_renda'.$cont]."'";
            $renda =str_replace(".","","$renda");
            $renda =str_replace(",",".","$renda");    
         endif;   
         $sql ="UPDATE CLIENTES_REFERENCIA 
                SET NOME         ='".$_POST['edt_pref_nome'.$cont]."'
                   ,CPF              ='".$_POST['edt_pref_cpf'.$cont]."'
                   ,RG               ='".$_POST['edt_pref_rg'.$cont]."'
                   ,ENDERECO         ='".$_POST['edt_pref_endereco'.$cont]."'
                   ,BAIRRO           ='".$_POST['edt_pref_bairro'.$cont]."'
                   ,CIDADE           ='".$_POST['edt_pref_municipio'.$cont]."'
                   ,UF               ='".$_POST['edt_pref_uf'.$cont]."'
                   ,CEP              ='".$_POST['edt_pref_cep'.$cont]."'
                   ,FONE1            ='".$_POST['edt_pref_fone1'.$cont]."'
                   ,FONE2            ='".$_POST['edt_pref_fone2'.$cont]."'
                   ,TIPO             ='".$_POST['seltipo'.$cont]."'
                   ,LOCAL_TRABALHO   ='".$_POST['edt_pref_trab'.$cont]."'
                   ,CARGO_TRABALHO   ='".$_POST['edt_pref_cargo'.$cont]."'
                   ,SALARIO_TRABALHO = ".$renda."
              WHERE CLIENTE = $codigo_cliente  
                AND CODIGO =".$_POST['idh_pref_cod'.$cont]."";
         if($db->Execute($sql) == false):
            alerta('error update: '.str_replace("\"","_",$db->ErrorMsg()).'');
            print $sql;
         endif;
      else:
         alerta('Click em uma referencia para alter-la!!');
      endif;
   endif;
   $db->SetFetchMode(ADODB_FETCH_ASSOC);
   $sql ="SELECT * FROM CLIENTES_REFERENCIA
                  WHERE CLIENTE = $codigo_cliente  
                  ORDER BY CODIGO";
   $result  = $db->Execute($sql) or alerta('error select: '.str_replace("\"","_",$db->ErrorMsg()).'');; 
   if($result->EOF):
      print "&lt;script>
                LeftPosition = (screen.width) ? (screen.width-700)/2 : 0;
                TopPosition = (screen.height) ? (screen.height-220)/2 : 0;
                result = window.showModalDialog('inserir_referencias_pessoais.php?vazio=','','dialogWidth:700px;dialogHeight:220px;dialogtop:'+TopPosition+';dialogleft:'+LeftPosition);
                window.close();
                  
             </script>"; 
   endif;
   
   $tipo = array(0 =>'Pai'
                ,1 =>'M&atilde;e'
                ,2 =>'filho(a)'
                ,3 =>'Tio(a)'
                ,4 =>'Irm&atilde;(o)'
                ,5 =>'Vizinho(a)'
                ,6 =>'Outros' 
                ,7 =>'Esposo(a)');

?>
<html>
   
   <head>
      <title>Refer&ecirc;ncias Pessoais</title>
      <base target="_top">
      <link href="css/style_referencia.css" rel="stylesheet" type="text/css"/>
      &lt;script>
       
      //document.fm_referencia.submit();
      function referencia(js_pos){
         var pos  = js_pos;
         var cont = document.fm_referencia.idh_while.value;
         document.fm_referencia.idh_pos.value = pos;
         for(var t = 1;t <= cont;t++){     
            if (pos == t){
               document.getElementById("edt_pref_nome"+pos).readOnly      = false;
               document.getElementById("edt_pref_cpf"+pos).readOnly       = false;
               document.getElementById("edt_pref_rg"+pos).readOnly        = false;
               document.getElementById("edt_pref_endereco"+pos).readOnly  = false;
               document.getElementById("edt_pref_bairro"+pos).readOnly    = false;
               document.getElementById("edt_pref_municipio"+pos).readOnly = false;
               document.getElementById("edt_pref_uf"+pos).readOnly        = false;
               document.getElementById("edt_pref_cep"+pos).readOnly       = false;
               document.getElementById("edt_pref_fone1"+pos).readOnly     = false;
               document.getElementById("edt_pref_fone2"+pos).readOnly     = false;
               document.getElementById("edt_pref_trab"+pos).readOnly      = false;
               document.getElementById("edt_pref_cargo"+pos).readOnly     = false;
               document.getElementById("edt_pref_renda"+pos).readOnly     = false;
               document.getElementById("seltipo"+pos).disabled            = false;
             }         
            else{
               document.getElementById("edt_pref_nome"+t).readOnly      = true;
               document.getElementById("edt_pref_cpf"+t).readOnly       = true;
               document.getElementById("edt_pref_rg"+t).readOnly        = true;
               document.getElementById("edt_pref_endereco"+t).readOnly  = true;
               document.getElementById("edt_pref_bairro"+t).readOnly    = true;
               document.getElementById("edt_pref_municipio"+t).readOnly = true;
               document.getElementById("edt_pref_uf"+t).readOnly        = true;
               document.getElementById("edt_pref_cep"+t).readOnly       = true;
               document.getElementById("edt_pref_fone1"+t).readOnly     = true;
               document.getElementById("edt_pref_fone2"+t).readOnly     = true;
               document.getElementById("edt_pref_trab"+t).readOnly      = true;
               document.getElementById("edt_pref_cargo"+t).readOnly     = true;
               document.getElementById("edt_pref_renda"+t).readOnly     = true;
               document.getElementById("seltipo"+t).disabled          = true;    
             }
         }
      }
      function nova_referencia(){
         var js_codcliente = document.fm_referencia.idh_codigo.value;
         LeftPosition = (screen.width) ? (screen.width-700)/2 : 0;
         TopPosition = (screen.height) ? (screen.height-220)/2 : 0;
         strParam = "cliente="+js_codcliente+"&vazio=1";
         var result = window.showModalDialog("inserir_referencias_pessoais.php?"+strParam,"","dialogWidth:700px;dialogHeight:220px;dialogtop:"+TopPosition+";dialogleft:"+LeftPosition);
         if (result == "reload")
            history.go(0);
            result = '';
       }
      function delete_ref(js){
         var del = document.fm_referencia.idh_pos.value;
         if (del != ""){
            if (confirm ("Deseja excluir essa referencia??"))
               {  
               document.fm_referencia.idh_delete.value = "sim";
               }
            else
               { 
               document.fm_referencia.idh_delete.value = "não";       
               }
            document.fm_referencia.method = "POST";             
            document.fm_referencia.action = "";             
            document.fm_referencia.submit();             
         }
         else{
            alert('Para excluir uma referencia de um click  sobre ela!');
         }   
            
      }
          
      
      
      </script>
      &lt;script src="includes/funcoes_javascript.js" type="text/javascript"></script>
   </head>
   <body>
      <form name="fm_referencia" method="POST" action="">
      <?php
         $top = 0;
         $w = 1;
         while (!$result->EOF):
          
            print "<div onclick='referencia($w);' style='top:".$top."px;position:absolute;
                                                         width:646px;
                                                         height:140px;
                                                         margin:10px;
                                                         border:#FFDFFF thin solid;'>
                      <div id='nome'>
                         <label>Nome  </label>
                         <input type='text' name='edt_pref_nome".$w."'      id='edt_pref_nome".$w."'   value='".$result->fields['NOME']."'readonly  size='60' class='input'>
                      </div>";
      ?>
                      <div id="tipo">
                         <label>Tipo</label>
                         <select name="seltipo<?php print $w;?>"  id="seltipo<?php print $w;?>" disabled class='input'>
                            <?php  
                            for($i = 0;$i<=7;$i++):   
                               $selected = "";
                               if ($i == $result->fields['TIPO']):
                                  $selected = 'selected';
                               endif;
                               print "<option $selected value='$i'>".$tipo[$i]."</option>";
                            endfor;
                               ?>   
                         </select>
                      </div>   
            <?php
            print "   <div id='cpf'>  
                         <label>CPF </label>&nbsp;&nbsp;&nbsp;
                         <input type='text' name='edt_pref_cpf".$w."'       id='edt_pref_cpf".$w."'       value='".$result->fields['CPF']."'readonly size='16' class='input'>
                      </div>   
                      <div id='rg'>
                         <label>RG</label>
                         <input type='text' name='edt_pref_rg".$w."'        id='edt_pref_rg".$w."'        value='".$result->fields['RG']."'readonly size='12' class='input'>
                      </div>   
                      <div id='end'>   
                         <label>Endereco</label>
                         <input type='text' name='edt_pref_endereco".$w."'  id='edt_pref_endereco".$w."'  value='".$result->fields['ENDERECO']."'readonly size='50' class='input'>
                      </div>      
                      <div id='bairro'>
                         &nbsp;<label>Bairro</label><br>
                         <input type='text' name='edt_pref_bairro".$w."'    id='edt_pref_bairro".$w."'    value='".$result->fields['BAIRRO']."'readonly class='input'>
                      </div>
                      <div id='municipio'>
                        &nbsp;<label>Municipio</label><br>
                        <input type='text' name='edt_pref_municipio".$w."' id='edt_pref_municipio".$w."' value='".$result->fields['CIDADE']."'readonly class='input'>
                      </div>   
                      <div id='uf'>   
                         <label>UF</label><br>
                         <input type='text' name='edt_pref_uf".$w."'        id='edt_pref_uf".$w."'        value='".$result->fields['UF']."'readonly class='input' size='1'>
                      </div>   
                      <div id='cep'>   
                          &nbsp;<label>CEP</label><br>
                         <input type='text' name='edt_pref_cep".$w."'       id='edt_pref_cep".$w."'       value='".$result->fields['CEP']."'readonly class='input' size='12'>
                      </div>   
                      <div id='fone1'>   
                          &nbsp;<label>FONE1</label><br>
                         <input type='text' name='edt_pref_fone1".$w."'     id='edt_pref_fone1".$w."'     value='".$result->fields['FONE1']."'readonly class='input' size='15'>
                      </div>   
                      <div id='fone2'>   
                          &nbsp;<label>FONE2</label><br>
                         <input type='text' name='edt_pref_fone2".$w."'     id='edt_pref_fone2".$w."'     value='".$result->fields['FONE2']."'readonly class='input' size='15'>
                      </div>   
                      <div id='local'>   
                         <label>Local Trabalho</label><br>
                         <input type='text' name='edt_pref_trab".$w."'      id='edt_pref_trab".$w."'      value='".$result->fields['LOCAL_TRABALHO']."'readonly class='input' size='46'>
                      </div>   
                      <div id='cargo'>   
                         <label>Cargo</label><br>
                         <input type='text' name='edt_pref_cargo".$w."'     id='edt_pref_cargo".$w."'     value='".$result->fields['CARGO_TRABALHO']."'readonly class='input' size='30'>
                      </div>    
                      <div id='renda'>    
                        <label>Renda</label><br>
                        <input type='text' name='edt_pref_renda".$w."'     id='edt_pref_renda".$w."'     value='".arredonda($result->fields['SALARIO_TRABALHO'])."'readonly class='input'>
                      </div>
                      <input type='hidden' name='idh_pref_cod".$w."' value='".$result->fields['CODIGO']."'
                   </div>";
         
              
            $result->MoveNext();
            $w += 1;
            $top +=145;
         endwhile; 
            ?><div class="teste">
            <input type="hidden" name="idh_while"  value="<?php print $w -1;?>">
            <input type="hidden" name="idh_codigo" value="<?php print $codigo_cliente;?>">
            <input type="hidden" name="idh_pos"    value="">
            <input type="hidden" name="idh_delete" value="">
            <input type="submit" name="btn_salvar" value="Salvar">
            <input type="button" name="btn_novo"   value="Novo" onclick="nova_referencia();">
            <input type="reset"  name="btn_reset"  value="Cancela" >
            <input type="button" name="btn_sair"   value="Sair"  onclick="fechar_janela();">
           <input type="button" name="btn_delete" value="Delete"  onclick="delete_ref()">
         </div>
      </form> 
   </body>
</html>

Editado por Jonathan Queiroz
Adcionar tag's (Jonathan)
Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,3k
    • Posts
      652,3k
×
×
  • Criar Novo...