Advertisement
Guest User

Funções Globais

a guest
Oct 21st, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1.  
  2.  function horario($nome,$dt1,$dt2){
  3.    
  4.    
  5.                 $indevidosCont = DB::table('tempindevidos')->
  6.                     where('email', '=', Auth::user()->email)->
  7.                     whereBetween(DB::raw("date_format(STR_TO_DATE(data, '%d/%m/%Y'),'%Y-%m-%d')"),[$dt1,$dt2])
  8.                     ->where('acesso','=',$nome)
  9.                     ->select('hora','horaTemp')
  10.                     -> get();
  11.                 $resultado =0;
  12.  
  13.         foreach($indevidosCont as $e){
  14.             if (preg_match('/^[0-9]{2}:[0-9]{2}$/', $e->hora)) {
  15.                 $hora1 = $e->hora;
  16.                 $hora2 = $e->horaTemp;
  17.                 $intervalo1 = new DateTime("T$hora1");
  18.                 $intervalo2 = new DateTime("T$hora2");
  19.                 $resultado += round(($intervalo2->getTimestamp() - $intervalo1->getTimestamp())/60);
  20.             }
  21.         }
  22.  
  23.         return $resultado;
  24.  }
  25.  
  26. //--------------------------------
  27.  
  28. function appImpressora($data,$hora,$email,$usuario){
  29.                
  30.        $retorno = DB::table('dados_computador')->
  31.             select('aplicacao')
  32.             ->where('email','=',$email)
  33.             ->where('data','=',$data)
  34.             ->where('usuario','=',$usuario)
  35.             ->where('aplicacao','!=','0')
  36.             ->where(DB::raw('substr(informacoes, 1, 5)'), '=' , $hora)
  37.             ->groupBy('aplicacao')
  38.             ->orderBy('id', 'desc')->first();
  39.        
  40.        return $retorno;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement