SetTitulo( "{$this->_instituicao} Diaria Valores" ); $this->processoAp = "295"; $this->addEstilo('localizacaoSistema'); } } class indice extends clsCadastro { var $cod_diaria_valores, $ref_funcionario_cadastro, $ref_cod_diaria_grupo, $estadual, $p100, $p75, $p50, $p25, $data_vigencia; function Inicializar() { $retorno = "Novo"; if ( isset( $_GET['cod_diaria_valores'] ) ) { $this->cod_diaria_valores = $_GET['cod_diaria_valores']; $db = new clsBanco(); $db->Consulta( "SELECT cod_diaria_valores, ref_funcionario_cadastro, ref_cod_diaria_grupo, estadual, p100, p75, p50, p25, data_vigencia FROM pmidrh.diaria_valores WHERE cod_diaria_valores='{$this->cod_diaria_valores}'" ); if ($db->ProximoRegistro()) { list( $this->cod_diaria_valores, $this->ref_funcionario_cadastro, $this->ref_cod_diaria_grupo, $this->estadual, $this->p100, $this->p75, $this->p50, $this->p25, $this->data_vigencia ) = $db->Tupla(); $this->fexcluir = true; $retorno = "Editar"; } } $this->url_cancelar = ( $retorno == "Editar" ) ? "diaria_valores_det.php?cod_diaria_valores={$this->cod_diaria_valores}" : "diaria_valores_lst.php"; $this->nome_url_cancelar = "Cancelar"; $nomeMenu = $retorno == "Editar" ? $retorno : "Cadastrar"; $localizacao = new LocalizacaoSistema(); $localizacao->entradaCaminhos( array( $_SERVER['SERVER_NAME']."/intranet" => "Início", "educar_index.php" => "i-Educar - Escola", "" => "{$nomeMenu} valores da diária" )); $this->enviaLocalizacao($localizacao->montar()); return $retorno; } function Gerar() { @session_start(); $this->pessoaFj = $_SESSION['id_pessoa']; session_write_close(); $this->campoOculto( "pessoaFj", $this->pessoaFj ); $this->campoOculto( "cod_diaria_valores", $this->cod_diaria_valores ); $grupo = array(); $grupo[""] = "Selecione o grupo"; $db = new clsBanco(); $db->Consulta( "SELECT cod_diaria_grupo, desc_grupo FROM pmidrh.diaria_grupo ORDER BY desc_grupo ASC" ); while ( $db->ProximoRegistro() ) { list( $cod_grupo, $nome ) = $db->Tupla(); $grupo[$cod_grupo] = $nome; } $this->campoLista( "ref_cod_diaria_grupo", "Grupo de diária", $grupo, $this->ref_cod_diaria_grupo ); if( ! is_numeric( $this->estadual ) ) { $this->estadual = 1; } $this->campoLista( "estadual", "Estadual", array( "Não", "Sim" ), $this->estadual ); if( $this->data_vigencia ) $this->data_vigencia = date( "d/m/Y", strtotime( $this->data_vigencia ) ); $this->campoData( "data_vigencia", "Data de Vigência", $this->data_vigencia ); $this->campoTexto( "p100", "Valor 100%", $this->p100, 20, 20 ); $this->campoTexto( "p75", "Valor 75%", $this->p75, 20, 20 ); $this->campoTexto( "p50", "Valor 50%", $this->p50, 20, 20 ); $this->campoTexto( "p25", "Valor 25%", $this->p25, 20, 20 ); } function Novo() { @session_start(); $this->ref_funcionario_cadastro = $_SESSION['id_pessoa']; session_write_close(); $campos = ""; $values = ""; $db = new clsBanco(); if( is_numeric( $this->ref_funcionario_cadastro ) ) { if( is_numeric( $this->ref_cod_diaria_grupo ) ) { if( is_numeric( $this->estadual ) && $this->estadual < 2 ) { if( $this->data_vigencia ) { $data = explode( "/", $this->data_vigencia ); $this->data_vigencia = "{$data[2]}-{$data[1]}-{$data[0]}"; $this->p100 = str_replace( ".", "", $this->p100 ); $this->p100 = str_replace( ",", ".", $this->p100 ); if( is_numeric( str_replace( ".", "", $this->p100 ) ) ) { $campos .= ", p100"; $values .= ", '{$this->p100}'"; } $this->p75 = str_replace( ".", "", $this->p75 ); $this->p75 = str_replace( ",", ".", $this->p75 ); if( is_numeric( str_replace( ".", "", $this->p75 ) ) ) { $campos .= ", p75"; $values .= ", '{$this->p75}'"; } $this->p50 = str_replace( ".", "", $this->p50 ); $this->p50 = str_replace( ",", ".", $this->p50 ); if( is_numeric( str_replace( ".", "", $this->p50 ) ) ) { $campos .= ", p50"; $values .= ", '{$this->p50}'"; } $this->p25 = str_replace( ".", "", $this->p25 ); $this->p25 = str_replace( ",", ".", $this->p25 ); if( is_numeric( str_replace( ".", "", $this->p25 ) ) ) { $campos .= ", p25"; $values .= ", '{$this->p25}'"; } $db->Consulta( "INSERT INTO pmidrh.diaria_valores( ref_funcionario_cadastro, ref_cod_diaria_grupo, estadual, data_vigencia $campos) VALUES( '{$this->ref_funcionario_cadastro}', '{$this->ref_cod_diaria_grupo}', '{$this->estadual}', '{$this->data_vigencia}' $values)" ); header( "location: diaria_valores_lst.php" ); die(); return true; } else { $this->mensagem = "Preencha corretamente o campo Data Vigencia"; } } else { $this->mensagem = "Preencha corretamente o campo Estadual"; } } else { $this->mensagem = "Preencha corretamente o campo Grupo de Diaria"; } } else { $this->mensagem = "Logue-se novamente para realizar esta operacao"; } return false; } function Editar() { @session_start(); $this->ref_funcionario_cadastro = $_SESSION['id_pessoa']; session_write_close(); $set = ""; $db = new clsBanco(); if( is_numeric( $this->ref_funcionario_cadastro ) ) { if( is_numeric( $this->ref_cod_diaria_grupo ) ) { if( is_numeric( $this->estadual ) && $this->estadual < 2 ) { if( $this->data_vigencia ) { if(is_numeric( $this->cod_diaria_valores ) ) { $data = explode( "/", $this->data_vigencia ); $this->data_vigencia = "{$data[2]}-{$data[1]}-{$data[0]}"; $campos .= ", data_vigencia"; $values .= ", '{$this->data_vigencia}'"; $this->p100 = str_replace( ".", "", $this->p100 ); $this->p100 = str_replace( ",", ".", $this->p100 ); if( is_numeric( str_replace( ".", "", $this->p100 ) ) ) { $campos .= ", p100 = '{$this->p100}'"; } $this->p75 = str_replace( ".", "", $this->p75 ); $this->p75 = str_replace( ",", ".", $this->p75 ); if( is_numeric( str_replace( ".", "", $this->p75 ) ) ) { $campos .= ", p75 = '{$this->p75}'"; } $this->p50 = str_replace( ".", "", $this->p50 ); $this->p50 = str_replace( ",", ".", $this->p50 ); if( is_numeric( str_replace( ".", "", $this->p50 ) ) ) { $campos .= ", p50 = '{$this->p50}'"; } $this->p25 = str_replace( ".", "", $this->p25 ); $this->p25 = str_replace( ",", ".", $this->p25 ); if( is_numeric( str_replace( ".", "", $this->p25 ) ) ) { $campos .= ", p25 = '{$this->p25}'"; } $db->Consulta( "UPDATE pmidrh.diaria_valores SET ref_funcionario_cadastro = '{$this->ref_funcionario_cadastro}', ref_cod_diaria_grupo = '{$this->ref_cod_diaria_grupo}', estadual = '{$this->estadual}', data_vigencia='{$this->data_vigencia}' $set WHERE cod_diaria_valores = '{$this->cod_diaria_valores}'" ); header( "location: diaria_valores_lst.php" ); die(); return true; } else { $this->mensagem = "Codigo de DIaria-Valor invalido!"; } } else { $this->mensagem = "Preencha corretamente o campo Data de Vigencia"; } } else { $this->mensagem = "Preencha corretamente o campo Estadual"; } } else { $this->mensagem = "Preencha corretamente o campo Grupo de Diaria"; } } else { $this->mensagem = "Logue-se novamente pra realizar esta operacao"; } return true; } function Excluir() { if( is_numeric( $this->cod_diaria_valores ) ) { $db = new clsBanco(); $db->Consulta( "DELETE FROM pmidrh.diaria_valores WHERE cod_diaria_valores={$this->cod_diaria_valores}" ); header( "location: diaria_valores_lst.php" ); die(); return true; } $this->mensagem = "Codigo de DIaria invalido!"; return false; } } $pagina = new clsIndex(); $miolo = new indice(); $pagina->addForm( $miolo ); $pagina->MakeAll(); ?>