예제 #1
0
 function Novo()
 {
     @session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     @session_write_close();
     $this->data_falta_atraso = Portabilis_Date_Utils::brToPgSQL($this->data_falta_atraso);
     $obj_permissoes = new clsPermissoes();
     $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7, sprintf('educar_falta_atraso_lst.php?ref_cod_servidor=%d&ref_cod_instituicao=%d', $this->ref_cod_servidor, $this->ref_cod_instituicao));
     if ($this->tipo == 1) {
         $obj = new clsPmieducarFaltaAtraso(NULL, $this->ref_cod_escola, $this->ref_cod_instituicao, NULL, $this->pessoa_logada, $this->ref_cod_servidor, $this->tipo, $this->data_falta_atraso, $this->qtd_horas, $this->qtd_min, $this->justificada, NULL, NULL, 1);
     } elseif ($this->tipo == 2) {
         $db = new clsBanco();
         $dia_semana = $db->CampoUnico(sprintf('(SELECT EXTRACT (DOW FROM date \'%s\') + 1 )', $this->data_falta_atraso));
         $obj_ser = new clsPmieducarServidor();
         $horas = $obj_ser->qtdhoras($this->ref_cod_servidor, $this->ref_cod_escola, $this->ref_cod_instituicao, $dia_semana);
         if ($horas) {
             $obj = new clsPmieducarFaltaAtraso(NULL, $this->ref_cod_escola, $this->ref_cod_instituicao, NULL, $this->pessoa_logada, $this->ref_cod_servidor, $this->tipo, $this->data_falta_atraso, $horas['hora'], $horas['min'], $this->justificada, NULL, NULL, 1);
         }
     }
     $cadastrou = $obj->cadastra();
     if ($cadastrou) {
         $this->mensagem .= 'Cadastro efetuado com sucesso.<br />';
         header('Location: ' . sprintf('educar_falta_atraso_lst.php?ref_cod_servidor=%d&ref_cod_instituicao=%d', $this->ref_cod_servidor, $this->ref_cod_instituicao));
         die;
     }
     $this->mensagem = 'Cadastro não realizado.<br />';
     echo "<!--\nErro ao cadastrar clsPmieducarFaltaAtraso\nvalores obrigatórios\nis_numeric( {$this->ref_cod_escola} ) && is_numeric({$this->ref_ref_cod_instituicao}) && is_numeric({$this->ref_usuario_exc}) && is_numeric({$this->ref_usuario_cad}) && is_numeric({$this->ref_cod_servidor}) && is_numeric({$this->tipo}) && is_string({$this->data_falta_atraso}) && is_numeric({$this->justificada})\n-->";
     return FALSE;
 }
 /**
  * Retorna a quantidade de horas compensadas.
  * @return array
  */
 function ServidorHorasCompensadas($int_ref_cod_servidor = NULL, $int_ref_cod_escola = NULL, $int_ref_cod_instituicao)
 {
     if (is_numeric($int_ref_cod_servidor)) {
         /*strtotime( '2006-06-06' );
           date( "Y-m-d", time );*/
         $db = new clsBanco();
         $db->Consulta("\n        SELECT\n          fac.data_inicio,\n          fac.data_fim\n        FROM\n          pmieducar.falta_atraso_compensado fac\n        WHERE\n          fac.ref_cod_servidor            = '{$int_ref_cod_servidor}'\n          AND fac.ref_cod_escola          = '{$int_ref_cod_escola}'\n          AND fac.ref_ref_cod_instituicao = '{$int_ref_cod_instituicao}'");
         while ($db->ProximoRegistro()) {
             $tupla = $db->Tupla();
             $resultado[] = $tupla;
         }
         $horas_total = 0;
         $minutos_total = 0;
         if ($resultado) {
             foreach ($resultado as $registro) {
                 $data_atual = strtotime($registro['data_inicio']);
                 $data_fim = strtotime($registro['data_fim']);
                 do {
                     $db2 = new clsBanco();
                     $dia_semana = $db2->CampoUnico("SELECT EXTRACT(DOW FROM (date '" . date('Y-m-d', $data_atual) . "') + 1)");
                     $obj_servidor = new clsPmieducarServidor();
                     $horas = $obj_servidor->qtdhoras($int_ref_cod_servidor, $int_ref_cod_escola, $int_ref_cod_instituicao, $dia_semana);
                     if ($horas) {
                         $horas_total += $horas['hora'];
                         $minutos_total += $horas['min'];
                     }
                     $data_atual += 86400;
                 } while ($data_atual <= $data_fim);
             }
         }
         $res['hora'] = $horas_total;
         $res['min'] = $minutos_total;
         return $res;
     }
     return FALSE;
 }