Advertisement
Guest User

Untitled

a guest
Aug 24th, 2015
86
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. //metodo usado a partir do PHP 5.1.2
  3. $sql = "SELECT *
  4.  FROM (SELECT P.PES_NUMERO AS MATRICULA,
  5.               P.PES_NOME AS NOME,
  6.               DECODE(P.PESSIT_NUMERO, 9, 'DEMITIDO', 8, 'ADMITIDO') AS SITUACAO,
  7.               C.ADMISSAO AS ADMISSAO,
  8.               C.RESCISAO AS RESCISAO,
  9.               (SELECT MAX(CP.CRED_NUMERO)
  10.                  FROM DEFAULT_ACESSO.CRED_PESSOAS CP
  11.                 WHERE CP.PES_NUMERO = P.PES_NUMERO
  12.                   AND SUBSTR(CP.CRED_NUMERO, 1, 1) = '1') AS CREDENCIAL
  13.          FROM DEFAULT_ACESSO.PESSOAS P, FOLHA.COLABORADORESADM C
  14.         WHERE P.PES_NUMERO = C.MATRICULA
  15.           AND C.ID_EMPRESAS = 1
  16.           AND C.ID_NEGOCIOS = 1
  17.           AND C.RESCISAO >= trunc(sysdate - 1)) A
  18. ORDER BY A.SITUACAO, A.MATRICULA";
  19.  
  20. $sql2 = "SELECT *
  21.  FROM (
  22.        SELECT A.MATRICULA
  23.          FROM (SELECT P.PES_NUMERO AS MATRICULA,
  24.                        P.PES_NOME AS NOME,
  25.                        DECODE(P.PESSIT_NUMERO, 9, 'DEMITIDO', 8, 'ADMITIDO') AS SITUACAO,
  26.                        C.ADMISSAO AS ADMISSAO,
  27.                        C.RESCISAO AS RESCISAO,
  28.                        (SELECT MAX(CP.CRED_NUMERO)
  29.                           FROM DEFAULT_ACESSO.CRED_PESSOAS CP
  30.                          WHERE CP.PES_NUMERO = P.PES_NUMERO
  31.                            AND SUBSTR(CP.CRED_NUMERO, 1, 1) = '1') AS CREDENCIAL
  32.                   FROM DEFAULT_ACESSO.PESSOAS P, FOLHA.COLABORADORESADM C
  33.                  WHERE P.PES_NUMERO = C.MATRICULA
  34.                    AND C.ID_EMPRESAS = 1
  35.                    AND C.ID_NEGOCIOS = 1
  36.                    AND P.PES_PIS IS NOT NULL
  37.                    AND (C.ADMISSAO >= trunc(sysdate - 1))) A)
  38. UNION
  39.  
  40. (
  41.  SELECT CP.PES_NUMERO MATRICULA
  42.    FROM DEFAULT_ACESSO.CRED_PESSOAS CP
  43.   WHERE TRUNC(CP.CRPES_DATAENTRADA) >= trunc(sysdate - 1)
  44.     AND SUBSTR(CP.CRED_NUMERO, 1, 1) = '1'
  45.     AND CP.CRPES_DATAENTRADA =
  46.         (SELECT MAX(CR.CRPES_DATAENTRADA)
  47.            FROM DEFAULT_ACESSO.CRED_PESSOAS CR
  48.           WHERE CR.PES_NUMERO = CP.PES_NUMERO)
  49.     AND CP.CRED_NUMERO NOT LIKE '100%')
  50. UNION
  51.  
  52. (
  53.  SELECT DISTINCT TT.PES_NUMERO_OLD MATRICULA
  54.    FROM DEFAULT_ACESSO.LOG_TEMPLATE_PESSOA TT
  55.   WHERE TT.TPL_TEMPLATE_OLD = TT.TPL_TEMPLATE_NEW
  56.     AND TRUNC(TT.DATA_ATU) >= trunc(sysdate - 1))";
  57.  
  58. echo "<html>
  59. <head>
  60.    <meta http-equiv='content-type' content='text/html; charset=utf-8' />  
  61.    <title>Atualizar relógios</title>
  62.  
  63.    <link rel='stylesheet' type='text/css' href='sources/css/jquery-ui.css'>
  64.    <link rel='stylesheet' type='text/css' href='sources/css/dataTables.jqueryui.css'>
  65.    <script type='text/javascript' language='javascript' src='sources/js/jquery-1.10.2.min.js'></script>
  66.    <script type='text/javascript' language='javascript' src='sources/js/jquery.dataTables.min.js'></script>
  67.    <script type='text/javascript' language='javascript' src='sources/js/dataTables.jqueryui.js'></script>
  68.    <script type='text/javascript' charset='utf-8'>
  69.      $(document).ready(function() {
  70.        $('#example').dataTable();
  71.      } );
  72.      $(document).ready(function() {
  73.        $('#example2').dataTable();
  74.      } );
  75.    </script>
  76. </head>";
  77.  
  78. echo "<body>";
  79. echo "<div align='center'>";
  80. echo "<img src='http://srv-cpf/assets/images/03_logo1.png'>";
  81. echo "<h2><font color=#00b38b> Atualização diária do relógios UAM</font></h2>";
  82. echo "</div>";
  83. echo "<div class='container'>";
  84.  
  85. $conn = oci_connect('xxx', 'xxx', '172.16.20.61/DBUAM');
  86. $dados = oci_parse($conn, $sql);
  87. if (oci_execute($dados, OCI_DEFAULT)){
  88.   echo "<table cellpadding='0' cellspacing='0' border='0' class='display' id='example'>";
  89.   echo "<thead>";
  90.   echo "<th>Colaboradores demitidos</th>";
  91.   echo "</thead>";
  92.   echo "<tbody>";
  93.   echo "<tr class='even gradeA'>";
  94.   while (oci_fetch($dados)){  
  95.   echo "<td>";
  96.   echo oci_result($dados, "MATRICULA");
  97.   echo "</td>";
  98.   echo "</tr>";
  99.   }
  100.   echo "</tbody>";
  101.   echo "</table>";
  102.   oci_close($conn);
  103. }else{
  104.   echo "Nenhum dado";
  105. };
  106.  
  107. echo "<br>";
  108.  
  109. $conn1 = oci_connect('xxx', 'xxx', '172.16.20.61/DBUAM');
  110. $dados2 = oci_parse($conn1, $sql2);
  111. if (oci_execute($dados2, OCI_DEFAULT)){
  112.   echo "<table cellpadding='0' cellspacing='0' border='0' class='display' id='example2'>";
  113.   echo "<thead>";
  114.   echo "<th>Colaboradores admitidos ou alteração de crachá</th>";
  115.   echo "</thead>";
  116.   echo "<tbody>";
  117.   echo "<tr class='even gradA'>";
  118.   while (oci_fetch($dados2)){
  119.   echo "<td>";
  120.   echo oci_result($dados2, "MATRICULA");
  121.   echo "</td>";
  122.   echo "</tr>";
  123.   }
  124.   echo "</tbody>";
  125.   echo "</table>";
  126. }else{
  127.   echo "Nenhum dado";
  128. };
  129.  
  130. echo "</div>";
  131. echo "</body>";
  132. echo "</html>";
  133. oci_close($conn1);
  134. ?>
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement