From 7f9d9e54ded28e25f306534bd42b43fbd8b0aa92 Mon Sep 17 00:00:00 2001 From: Eriksen Costa Paixão Date: Mon, 10 May 2010 19:11:56 +0000 Subject: [PATCH] Refactoring para coding standards --- ieducar/intranet/educar_turma_cad.php | 2929 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 file changed, 1388 insertions(+), 1541 deletions(-) diff --git a/ieducar/intranet/educar_turma_cad.php b/ieducar/intranet/educar_turma_cad.php index 5ab6a2d..97b22d8 100644 --- a/ieducar/intranet/educar_turma_cad.php +++ b/ieducar/intranet/educar_turma_cad.php @@ -1,1664 +1,1511 @@ + * + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. + * + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Prefeitura Municipal de Itajaí + * @category i-Educar + * @license @@license@@ + * @package iEd_Pmieducar + * @since Arquivo disponível desde a versão 1.0.0 + * @version $Id$ + */ + +require_once 'include/clsBase.inc.php'; +require_once 'include/clsCadastro.inc.php'; +require_once 'include/clsBanco.inc.php'; +require_once 'include/pmieducar/geral.inc.php'; + +/** + * clsIndexBase class. + * + * @author Prefeitura Municipal de Itajaí + * @category i-Educar + * @license @@license@@ + * @package iEd_Pmieducar + * @since Classe disponível desde a versão 1.0.0 + * @version @@package_version@@ + */ class clsIndexBase extends clsBase { - function Formular() - { - $this->SetTitulo( "{$this->_instituicao} i-Educar - Turma" ); - $this->processoAp = "586"; - //$this->scripts[] = "ajax"; - } + function Formular() + { + $this->SetTitulo($this->_instituicao . ' i-Educar - Turma'); + $this->processoAp = 586; + } } +/** + * indice class. + * + * @author Prefeitura Municipal de Itajaí + * @category i-Educar + * @license @@license@@ + * @package iEd_Pmieducar + * @since Classe disponível desde a versão 1.0.0 + * @version @@package_version@@ + */ class indice extends clsCadastro { - /** - * Referencia pega da session para o idpes do usuario atual - * - * @var int - */ - var $pessoa_logada; - - var $cod_turma; - var $ref_usuario_exc; - var $ref_usuario_cad; - var $ref_ref_cod_serie; - var $ref_ref_cod_escola; - var $ref_cod_infra_predio_comodo; - var $nm_turma; - var $sgl_turma; - var $max_aluno; - var $multiseriada; - var $data_cadastro; - var $data_exclusao; - var $ativo; - var $ref_cod_turma_tipo; - var $hora_inicial; - var $hora_final; - var $hora_inicio_intervalo; - var $hora_fim_intervalo; - - var $ref_cod_instituicao; - var $ref_cod_curso; - var $ref_cod_escola; - - var $padrao_ano_escolar; - - var $ref_cod_regente; - var $ref_cod_instituicao_regente; - - var $ref_ref_cod_serie_mult; - -//------INCLUI MODULO------// - var $turma_modulo; - var $incluir_modulo; - var $excluir_modulo; - -//------INCLUI DIA_SEMANA------// - var $dia_semana; - var $ds_hora_inicial; - var $ds_hora_final; - var $turma_dia_semana; - var $incluir_dia_semana; - var $excluir_dia_semana; - var $visivel; - - var $dias_da_semana = array( '' => 'Selecione', 1 => 'Domingo', 2 => 'Segunda', 3 => 'Terça', 4 => 'Quarta', 5 => 'Quinta', 6 => 'Sexta', 7 => 'Sábado' ); - - function Inicializar() - { - $retorno = "Novo"; - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - - $this->cod_turma=$_GET["cod_turma"]; - - $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_cadastra( 586, $this->pessoa_logada, 7, "educar_turma_lst.php" ); - - if ( is_numeric( $this->cod_turma ) ) { - $obj = new clsPmieducarTurma( $this->cod_turma ); - $registro = $obj->detalhe(); - $obj_esc = new clsPmieducarEscola( $registro["ref_ref_cod_escola"] ); - $det_esc = $obj_esc->detalhe(); - $obj_ser = new clsPmieducarSerie( $registro["ref_ref_cod_serie"] ); - $det_ser = $obj_ser->detalhe(); - $this->ref_cod_escola = $det_esc["cod_escola"]; - $this->ref_cod_instituicao = $det_esc["ref_cod_instituicao"]; - $this->ref_cod_curso = $det_ser["ref_cod_curso"]; - $obj_curso = new clsPmieducarCurso(($this->ref_cod_curso)); - $det_curso = $obj_curso->detalhe(); - $this->padrao_ano_escolar = $det_curso['padrao_ano_escolar']; - if ( $registro ) - { - foreach ( $registro AS $campo => $val ) // passa todos os valores obtidos no registro para atributos do objeto - $this->$campo = $val; - - $this->fexcluir = $obj_permissoes->permissao_excluir( 586, $this->pessoa_logada, 7, "educar_turma_lst.php" ); - $retorno = "Editar"; - } - } - $this->url_cancelar = ( $retorno == "Editar" ) ? "educar_turma_det.php?cod_turma={$registro["cod_turma"]}" : "educar_turma_lst.php"; - $this->nome_url_cancelar = "Cancelar"; - return $retorno; - } - - function Gerar() - { - if( $_POST ) - foreach( $_POST AS $campo => $val ) - $this->$campo = ( $this->$campo ) ? $this->$campo : $val; - - //echo "
";print_r($this);
-
-		$this->campoOculto( "cod_turma", $this->cod_turma );
-
-		// foreign keys
-		$obrigatorio = false;
-		$instituicao_obrigatorio = true;
-	    $escola_curso_obrigatorio = true;
-	    $curso_obrigatorio = true;
-		$get_escola = true;
-//		$get_escola_curso = true;
-		$get_escola_curso_serie = false;
-		$sem_padrao = true;
-		$get_curso = true;
-		/*if( isset($_GET["cl"]) )
-		{*/
-			include("include/pmieducar/educar_campo_lista.php");
-		/*}
-		else
-		{
-			include("include/pmieducar/educar_campo_lista.php");
-		}*/
-
-		if ( $this->ref_cod_escola )
-		{
-			$this->ref_ref_cod_escola = $this->ref_cod_escola;
-		}
-
-		
-				/**
-				 * *********************************COLOCADO*****************************************/
-//			 getEscolaCursoSerie();
-		$opcoes_serie = array( "" => "Selecione" );
-		// EDITAR
-		if ( $this->ref_cod_curso )
-		{
-			$obj_serie = new clsPmieducarSerie();
-			$obj_serie->setOrderby("nm_serie ASC");
-			$lst_serie = $obj_serie->lista( null,null,null,$this->ref_cod_curso,null,null,null,null,null,null,null,null,1);
-			if ( is_array( $lst_serie ) && count( $lst_serie ) )
-			{
-				foreach ( $lst_serie as $serie )
-				{
-					$opcoes_serie["{$serie["cod_serie"]}"] = $serie['nm_serie'];
-				}
-			}
-		}
-		$script = "javascript:showExpansivelIframe(520, 550, 'educar_serie_cad_pop.php?ref_ref_cod_serie=sim');";
-		if ($this->ref_cod_instituicao && $this->ref_cod_escola	 && $this->ref_cod_curso)
-		{
-			$script = "";
-//			$this->campoLista( "ref_ref_cod_serie", "Série", $opcoes_serie, $this->ref_cod_serie, "", false, "", $script, true);
-		}
-		else
-		{
-			$script = "";
-			
-		}
-		$this->campoLista( "ref_ref_cod_serie", "Série", $opcoes_serie, $this->ref_ref_cod_serie, "", false, "", $script);
-		
-		/***********************************COLOCADO****************************************/
-		
-//		if( class_exists( "clsPmieducarTurma" ) )
-//		{
-//			$todas_turmas_sala  = "turma_sala = new Array();\n";
-//			$objTemp = new clsPmieducarTurma();
-//			$lista = $objTemp->lista( null,null,null,null,null,null,null,null,null,null,null,null,null,null,1 );
-//			if ( is_array( $lista ) && count( $lista ) )
-//			{
-//				foreach ( $lista as $registro )
-//				{
-//					$obj_infra_predio_comodo = new clsPmieducarInfraPredioComodo( $registro['ref_cod_infra_predio_comodo'] );
-//					$det_infra_predio_comodo = $obj_infra_predio_comodo->detalhe();
-//
-//					$obj_infra_predio = new clsPmieducarInfraPredio( $det_infra_predio_comodo["ref_cod_infra_predio"] );
-//					$det_infra_prefalsedio = $obj_infra_predio->detalhe();
-//
-//					$registro['hora_inicial'] = substr($registro['hora_inicial'],0,5);
-//					$registro['hora_final'] = substr($registro['hora_final'],0,5);
-//
-//					$todas_turmas_sala .= "turma_sala[turma_sala.length] = new Array( {$registro["cod_turma"]}, '{$registro['ref_cod_infra_predio_comodo']}', '{$det_infra_predio['ref_cod_escola']}', '{$registro['hora_inicial']}', '{$registro['hora_final']}' );\n";
-//				}
-//			}
-//			echo "";
-//		}
-
-	//-------------------INFRA PREDIO COMODO----------------------//
-		$opcoes = array( "" => "Selecione" );
-		//if( class_exists( "clsPmieducarInfraPredio" ) && class_exists( "clsPmieducarInfraPredioComodo" ) )
-		//{
-//			$todos_comodos_predios  = "comodo = new Array();\n";
-//			$obj_infra_predio = new clsPmieducarInfraPredio();
-//			$obj_infra_predio->setOrderby("nm_predio ASC");
-//			$lst_infra_predio = $obj_infra_predio->lista( null,null,null,null,null,null,null,null,null,null,null,1 );
-//			if ( is_array( $lst_infra_predio ) && count( $lst_infra_predio ) )
-//			{
-//				foreach ( $lst_infra_predio as $predio )
-//				{
-//					$obj_infra_predio_comodo = new clsPmieducarInfraPredioComodo();
-//					$lst_infra_predio_comodo = $obj_infra_predio_comodo->lista( null,null,null,null,$predio["cod_infra_predio"],null,null,null,null,null,null,null,1 );
-//					if ( is_array( $lst_infra_predio_comodo ) && count( $lst_infra_predio_comodo ) )
-//					{
-//						foreach ( $lst_infra_predio_comodo as $comodo )
-//						{
-//							$todos_comodos_predios .= "comodo[comodo.length] = new Array( {$comodo["cod_infra_predio_comodo"]}, '{$comodo['nm_comodo']}', {$predio["ref_cod_escola"]} );\n";
-//						}
-//					}
-//				}
-//			}
-//			echo "";
-
-			// EDITAR
-			if ( $this->ref_ref_cod_escola )
-			{
-				$obj_infra_predio = new clsPmieducarInfraPredio();
-				$obj_infra_predio->setOrderby("nm_predio ASC");
-				$lst_infra_predio = $obj_infra_predio->lista( null,null,null,$this->ref_ref_cod_escola,null,null,null,null,null,null,null,1 );
-				if ( is_array( $lst_infra_predio ) && count( $lst_infra_predio ) )
-				{
-					foreach ( $lst_infra_predio as $predio )
-					{
-						$obj_infra_predio_comodo = new clsPmieducarInfraPredioComodo();
-						$lst_infra_predio_comodo = $obj_infra_predio_comodo->lista( null,null,null,null,$predio["cod_infra_predio"],null,null,null,null,null,null,null,1 );
-						if ( is_array( $lst_infra_predio_comodo ) && count( $lst_infra_predio_comodo ) )
-						{
-							foreach ( $lst_infra_predio_comodo as $comodo )
-							{
-								$opcoes["{$comodo["cod_infra_predio_comodo"]}"] = $comodo['nm_comodo'];
-							}
-						}
-					}
-				}
-			}
-		//}
-		////else
-		//{
-			//echo "";
-			//$opcoes_cursos_escola = array( "" => "Erro na geração" );
-		//}
-		$this->campoLista( "ref_cod_infra_predio_comodo", "Sala", $opcoes, $this->ref_cod_infra_predio_comodo,null,null,null,null,null,false);
-
-		$array_servidor = array( '' => "Selecione um servidor" );
-		if($this->ref_cod_regente)
-		{
-			$obj_pessoa = new clsPessoa_($this->ref_cod_regente);
-			$det = $obj_pessoa->detalhe();
-			$array_servidor[$this->ref_cod_regente] = $det['nome'];
-
-		}
-		$this->campoListaPesq( "ref_cod_regente", "Professor/Regente", $array_servidor, $this->ref_cod_regente, "", "", false, "", "", null, null, "", true, false, false);
-	//-------------------TURMA TIPO----------------------//
-		$opcoes = array( "" => "Selecione" );
-//		$todos_tipos_turma  = "tipo_turma = new Array();\n";
-//		$objTemp = new clsPmieducarTurmaTipo();
-//		$objTemp->setOrderby("nm_tipo ASC");
-//		$lista = $objTemp->lista( null,null,null,null,null,null,null,null,null,1 );
-//		if ( is_array( $lista ) && count( $lista ) )
-//		{
-//			foreach ( $lista as $registro )
-//			{
-//				$todos_tipos_turma .= "tipo_turma[tipo_turma.length] = new Array( {$registro["cod_turma_tipo"]}, '{$registro['nm_tipo']}', {$registro["ref_cod_instituicao"]} );\n";
-//			}
-//		}
-//		echo "";
-
-		// EDITAR
-		if ($this->ref_cod_instituicao)
-		{
-			$objTemp = new clsPmieducarTurmaTipo();
-			$objTemp->setOrderby("nm_tipo ASC");
-			$lista = $objTemp->lista( null,null,null,null,null,null,null,null,null,1,$this->ref_cod_instituicao );
-			if ( is_array( $lista ) && count( $lista ) )
-			{
-				foreach ( $lista as $registro )
-				{
-					$opcoes["{$registro['cod_turma_tipo']}"] = "{$registro['nm_tipo']}";
-				}
-			}
-		}
-
-		
-		$script = "javascript:showExpansivelIframe(520, 170, 'educar_turma_tipo_cad_pop.php');";
-		if ($this->ref_cod_instituicao && $this->ref_cod_escola	 && $this->ref_cod_curso)
-		{
-			$script = "";
-//			$this->campoLista( "ref_ref_cod_serie", "Série", $opcoes_serie, $this->ref_cod_serie, "", false, "", $script, true);
-		}
-		else
-		{
-			$script = "";
-			
-		}
-		
-		$this->campoLista( "ref_cod_turma_tipo", "Tipo de Turma", $opcoes, $this->ref_cod_turma_tipo, "", false, "", $script );
-
-		// text
-		$this->campoTexto( "nm_turma", "Turma", $this->nm_turma, 30, 255, true );
-		$this->campoTexto( "sgl_turma", "Sigla", $this->sgl_turma, 15, 15, false );
-
-		$this->campoNumero( "max_aluno", "Máximo de Alunos", $this->max_aluno, 3, 3, true );
-		$this->campoCheck("visivel", "Ativo", dbBool($this->visivel));
-		// checkbox
-		$this->campoCheck( "multiseriada", "Multi-Seriada", $this->multiseriada, "", false, false );
-
-		$this->campoLista("ref_ref_cod_serie_mult","Série",array('' => 'Selecione'),'',"",false,"","","",false);
-		$this->campoOculto("ref_ref_cod_serie_mult_",$this->ref_ref_cod_serie_mult);
-		
-		
-		$this->campoQuebra2();
-
-//-----------------SE EM CURSO, PADRAO_ANO_ESCOLA == 1-------------------//
-		// hora
-		$this->campoHora( "hora_inicial", "Hora Inicial", $this->hora_inicial,false );
-		$this->campoHora( "hora_final", "Hora Final", $this->hora_final,false );
-		$this->campoHora( "hora_inicio_intervalo", "Hora Início Intervalo", $this->hora_inicio_intervalo,false );
-		$this->campoHora( "hora_fim_intervalo", "Hora Fim Intervalo", $this->hora_fim_intervalo,false );
-
-//-----------------SENAO, PADRAO_ANO_ESCOLA == 0-------------------//
-
-	//---------------------INCLUI MODULO---------------------//
-		$this->campoQuebra();
-
-		if ( $_POST["turma_modulo"] )
-			$this->turma_modulo = unserialize( urldecode( $_POST["turma_modulo"] ) );
-		$qtd_modulo = ( count( $this->turma_modulo ) == 0 ) ? 1 : ( count( $this->turma_modulo ) + 1);
-		if( is_numeric( $this->cod_turma) && !$_POST)
-		{
-			$obj = new clsPmieducarTurmaModulo();
-			$registros = $obj->lista( $this->cod_turma );
-			if( $registros )
-			{
-				foreach ( $registros AS $campo )
-				{
-					$this->turma_modulo[$campo[$qtd_modulo]]["sequencial_"] = $campo["sequencial"];
-					$this->turma_modulo[$campo[$qtd_modulo]]["ref_cod_modulo_"] = $campo["ref_cod_modulo"];
-					$this->turma_modulo[$campo[$qtd_modulo]]["data_inicio_"]  = dataFromPgToBr($campo["data_inicio"]);
-					$this->turma_modulo[$campo[$qtd_modulo]]["data_fim_"]  = dataFromPgToBr($campo["data_fim"]);
-					$qtd_modulo++;
-				}
-			}
-		}
-		if ( $_POST["ref_cod_modulo"] && $_POST["data_inicio"] && $_POST["data_fim"] )
-		{
-			$this->turma_modulo[$qtd_modulo]["sequencial_"] = $qtd_modulo;
-			$this->turma_modulo[$qtd_modulo]["ref_cod_modulo_"] = $_POST["ref_cod_modulo"];
-			$this->turma_modulo[$qtd_modulo]["data_inicio_"] = $_POST["data_inicio"];
-			$this->turma_modulo[$qtd_modulo]["data_fim_"] = $_POST["data_fim"];
-			$qtd_modulo++;
-			unset( $this->ref_cod_modulo );
-			unset( $this->data_inicio );
-			unset( $this->data_fim );
-		}
-
-		$this->campoOculto( "excluir_modulo", "" );
-		$qtd_modulo = 1;
-		unset($aux);
-
-		if ( $this->turma_modulo )
-		{
-			foreach ( $this->turma_modulo as $campo )
-			{
-				if ( $this->excluir_modulo == $campo["sequencial_"] )
-				{
-					$this->turma_modulo[$campo["sequencial"]] = null;
-					$this->excluir_modulo	= null;
-				}
-				else
-				{
-					$obj_modulo = new clsPmieducarModulo($campo["ref_cod_modulo_"]);
-					$det_modulo = $obj_modulo->detalhe();
-					$nm_tipo_modulo = $det_modulo["nm_tipo"];
-					$this->campoTextoInv( "ref_cod_modulo_{$campo["sequencial_"]}", "", $nm_tipo_modulo, 30, 255, false, false, true,"","","","","ref_cod_modulo" );
-					$this->campoTextoInv( "data_inicio_{$campo["sequencial_"]}", "", $campo["data_inicio_"], 10, 10, false, false, true,"","","","","" );
-					$this->campoTextoInv( "data_fim_{$campo["sequencial_"]}", "", $campo["data_fim_"], 10, 10, false, false, false, "", "__nome}.submit();\">","","","" );
-					$aux[$qtd_modulo]["sequencial_"] = $qtd_modulo;
-					$aux[$qtd_modulo]["ref_cod_modulo_"] = $campo["ref_cod_modulo_"];
-					$aux[$qtd_modulo]["data_inicio_"] = $campo["data_inicio_"];
-					$aux[$qtd_modulo]["data_fim_"] = $campo["data_fim_"];
-					$qtd_modulo++;
-				}
-
-			}
-			unset($this->turma_modulo);
-			$this->turma_modulo = $aux;
-		}
-		$this->campoOculto( "turma_modulo", serialize( $this->turma_modulo ) );
-
-	//-------------------MODULO----------------------//
-		// foreign keys
-		$opcoes = array( "" => "Selecione" );
-		//if( class_exists( "clsPmieducarModulo" ) )
-		//{
-//			$todos_modulos  = "modulo = new Array();\n";
-//			$objTemp = new clsPmieducarModulo();
-//			$objTemp->setOrderby("nm_tipo ASC");
-//			$lista = $objTemp->lista(null,null,null,null,null,null,null,null,null,null,null,1);
-//			if ( is_array( $lista ) && count( $lista ) )
-//			{
-//				foreach ( $lista as $registro )
-//				{
-//					$todos_modulos .= "modulo[modulo.length] = new Array( {$registro["cod_modulo"]}, '{$registro['nm_tipo']}', '{$registro["ref_cod_instituicao"]}' );\n";
-//				}
-//			}
-//			echo "";
-
-			// EDITAR
-			if ($this->ref_cod_instituicao)
-			{
-				$objTemp = new clsPmieducarModulo();
-				$objTemp->setOrderby("nm_tipo ASC");
-				$lista = $objTemp->lista(null,null,null,null,null,null,null,null,null,null,null,1,$this->ref_cod_instituicao);
-				if ( is_array( $lista ) && count( $lista ) )
-				{
-					foreach ( $lista as $registro )
-					{
-						$opcoes["{$registro['cod_modulo']}"] = "{$registro['nm_tipo']}";
-					}
-				}
-			}
-		//}
-		//else
-		//{
-		//	echo "";
-		//	$opcoes = array( "" => "Erro na geracao" );
-		//}
-		$this->campoLista( "ref_cod_modulo", "Módulo", $opcoes, $this->ref_cod_modulo,null,null,null,null,null,false );
-		$this->campoData( "data_inicio", "Data Início", $this->data_inicio,false );
-		$this->campoData( "data_fim", "Data Fim", $this->data_fim,false );
-
-		$this->campoOculto( "incluir_modulo", "" );
-		$this->campoRotulo( "bt_incluir_modulo", "Módulo", "adicionar" );
-
-		$this->campoQuebra();
-	//---------------------FIM INCLUI MODULO---------------------//
-
-
-	//-----------------------INCLUI DIA SEMANA------------------------//
-		$this->campoQuebra();
-
-		if ( $_POST["turma_dia_semana"] )
-			$this->turma_dia_semana = unserialize( urldecode( $_POST["turma_dia_semana"] ) );
-		if( is_numeric( $this->cod_turma ) && !$_POST )
-		{
-			$obj = new clsPmieducarTurmaDiaSemana();
-			$registros = $obj->lista( null,$this->cod_turma );
-			if( $registros )
-			{
-				foreach ( $registros AS $campo )
-				{
-					$aux["dia_semana_"]= $campo["dia_semana"];
-					$aux["hora_inicial_"]= $campo["hora_inicial"];
-					$aux["hora_final_"]= $campo["hora_final"];
-					$this->turma_dia_semana[] = $aux;
-				}
-			}
-		}
-
-		unset($aux);
-
-		if ( $_POST["dia_semana"] && $_POST["ds_hora_inicial"] && $_POST["ds_hora_final"] )
-		{
-			$aux["dia_semana_"] = $_POST["dia_semana"];
-			$aux["hora_inicial_"] = $_POST["ds_hora_inicial"];
-			$aux["hora_final_"] = $_POST["ds_hora_final"];
-			$this->turma_dia_semana[] = $aux;
-			unset( $this->dia_semana );
-			unset( $this->ds_hora_inicial );
-			unset( $this->ds_hora_final );
-		}
-
-		$this->campoOculto( "excluir_dia_semana", "" );
-		unset($aux);
-
-		if ( $this->turma_dia_semana )
-		{
-			foreach ( $this->turma_dia_semana as $key => $dias_semana)
-			{
-				if ( $this->excluir_dia_semana == $dias_semana["dia_semana_"] )
-				{
-					unset($this->turma_dia_semana[$key]);
-					unset($this->excluir_dia_semana);
-				}
-				else
-				{
-					$nm_dia_semana = $this->dias_da_semana[$dias_semana["dia_semana_"]];
-
-					$this->campoTextoInv( "dia_semana_{$dias_semana["dia_semana_"]}", "", $nm_dia_semana, 8, 8, false, false, true,"","","","","dia_semana" );
-					$this->campoTextoInv( "hora_inicial_{$dias_semana["dia_semana_"]}", "", $dias_semana['hora_inicial_'], 5, 5, false, false, true, "","","","","ds_hora_inicial_" );
-					$this->campoTextoInv( "hora_final_{$dias_semana["dia_semana_"]}", "", $dias_semana['hora_final_'], 5, 5, false, false, false, "", "__nome}.submit();\">","","","ds_hora_final_" );
-					$aux["dia_semana_"] = $dias_semana["dia_semana_"];
-					$aux["hora_inicial_"] = $dias_semana['hora_inicial_'];
-					$aux["hora_final_"] = $dias_semana['hora_final_'];
-				}
-			}
-		}
-		$this->campoOculto( "turma_dia_semana", serialize( $this->turma_dia_semana ) );
-
-		if( class_exists( "clsPmieducarTurmaDiaSemana" ) )
-		{
-			$opcoes = $this->dias_da_semana;
-		}
-		else
-		{
-			echo "";
-			$opcoes = array( "" => "Erro na geração" );
-		}
-		$this->campoLista( "dia_semana", "Dia Semana", $opcoes, $this->dia_semana,null,false,"","",false,false);
-		$this->campoHora( "ds_hora_inicial", "Hora Inicial", $this->ds_hora_inicial,false );
-		$this->campoHora( "ds_hora_final", "Hora Final", $this->ds_hora_final,false );
-
-		$this->campoOculto( "incluir_dia_semana", "" );
-		$this->campoRotulo( "bt_incluir_dia_semana", "Dia Semana", "adicionar" );
-
-		$this->campoQuebra();
-	//-----------------------FIM DIA SEMANA------------------------//
-
-		$this->campoOculto( "padrao_ano_escolar", $this->padrao_ano_escolar );
-
-		$this->acao_enviar = "valida()";
-	}
-
-	function Novo()
-	{
-		@session_start();
-		 $this->pessoa_logada = $_SESSION['id_pessoa'];
-		@session_write_close();
-		$this->ref_cod_instituicao_regente = $this->ref_cod_instituicao;
-		if ( $this->multiseriada == "on" )
-			$this->multiseriada = 1;
-		else
-			$this->multiseriada = 0;
-		
-		if ($this->visivel == "on")
-		{
-			$this->visivel = true;
-		}
-		else 
-		{
-			$this->visivel = false;
-		}
-
-		// não segue o padrao do curso
-		if ($this->padrao_ano_escolar == 0)
-		{
-			$this->turma_modulo = unserialize( urldecode( $this->turma_modulo ) );
-			$this->turma_dia_semana = unserialize( urldecode( $this->turma_dia_semana ) );
-			if ($this->turma_modulo && $this->turma_dia_semana)
-			{
-				$obj = new clsPmieducarTurma( null, null, $this->pessoa_logada, $this->ref_ref_cod_serie, $this->ref_cod_escola, $this->ref_cod_infra_predio_comodo, $this->nm_turma, $this->sgl_turma, $this->max_aluno, $this->multiseriada, null, null, 1, $this->ref_cod_turma_tipo,null,null,null,null,$this->ref_cod_regente,$this->ref_cod_instituicao_regente,$this->ref_cod_instituicao,$this->ref_cod_curso,$this->ref_ref_cod_serie_mult,$this->ref_cod_escola, $this->visivel);
-				$cadastrou = $obj->cadastra();
-				if( $cadastrou )
-				{
-				//--------------CADASTRA MODULO--------------//
-					foreach ( $this->turma_modulo AS $campo )
-					{
-						$campo["data_inicio_"] = dataToBanco($campo["data_inicio_"]);
-						$campo["data_fim_"] = dataToBanco($campo["data_fim_"]);
-
-						$obj = new clsPmieducarTurmaModulo( $cadastrou, $campo["ref_cod_modulo_"], $campo["sequencial_"], $campo["data_inicio_"], $campo["data_fim_"] );
-						$cadastrou1 = $obj->cadastra();
-						if( !$cadastrou1 )
-						{
-							$this->mensagem = "Cadastro não realizado.
"; - echo ""; - return false; - } - } - //--------------FIM CADASTRA MODULO--------------// - - //-----------------------CADASTRA DIA SEMANA------------------------// - foreach ( $this->turma_dia_semana AS $campo ) - { - $obj = new clsPmieducarTurmaDiaSemana( $campo["dia_semana_"], $cadastrou, $campo["hora_inicial_"], $campo["hora_final_"] ); - $cadastrou2 = $obj->cadastra(); - if ( !$cadastrou2 ) - { - $this->mensagem = "Cadastro não realizado.
"; - echo ""; - return false; - } - } - $this->mensagem .= "Cadastro efetuado com sucesso.
"; - header( "Location: educar_turma_lst.php" ); - die(); - return true; - //-----------------------FIM CADASTRA DIA SEMANA------------------------// - } - $this->mensagem = "Cadastro não realizado.
"; - echo ""; - return false; - } - echo ""; - $this->mensagem = "Cadastro não realizado.
"; - return false; - } // segue o padrao do curso - else if ($this->padrao_ano_escolar == 1) - { - $obj = new clsPmieducarTurma( null, null, $this->pessoa_logada, $this->ref_ref_cod_serie, $this->ref_cod_escola, $this->ref_cod_infra_predio_comodo, $this->nm_turma, $this->sgl_turma, $this->max_aluno, $this->multiseriada, null, null, 1, $this->ref_cod_turma_tipo, $this->hora_inicial, $this->hora_final, $this->hora_inicio_intervalo, $this->hora_fim_intervalo,$this->ref_cod_regente,$this->ref_cod_instituicao_regente,$this->ref_cod_instituicao,$this->ref_cod_curso, $this->ref_ref_cod_serie_mult,$this->ref_cod_escola, $this->visivel ); - $cadastrou = $obj->cadastra(); - if( $cadastrou ) - { - $this->mensagem .= "Cadastro efetuado com sucesso.
"; - header( "Location: educar_turma_lst.php" ); - die(); - return true; - } - $this->mensagem = "Cadastro não realizado.
"; - echo ""; - return false; - } - } - - function Editar() - { - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - $this->ref_cod_instituicao_regente = $this->ref_cod_instituicao; - - if ( $this->multiseriada == "on" ) - $this->multiseriada = 1; - else - $this->multiseriada = 0; - - if ($this->visivel == "on") - { - $this->visivel = true; - } - else - { - $this->visivel = false; - } - - // não segue o padrao do curso - if ($this->padrao_ano_escolar == 0) - { - $this->turma_modulo = unserialize( urldecode( $this->turma_modulo ) ); - $this->turma_dia_semana = unserialize( urldecode( $this->turma_dia_semana ) ); - if ($this->turma_modulo && $this->turma_dia_semana) - { - $obj = new clsPmieducarTurma( $this->cod_turma, $this->pessoa_logada, null, $this->ref_ref_cod_serie, $this->ref_cod_escola, $this->ref_cod_infra_predio_comodo, $this->nm_turma, $this->sgl_turma, $this->max_aluno, $this->multiseriada, null, null, 1, $this->ref_cod_turma_tipo,null,null,null,null,$this->ref_cod_regente,$this->ref_cod_instituicao_regente,$this->ref_cod_instituicao,$this->ref_cod_curso, $this->ref_ref_cod_serie_mult, $this->ref_cod_escola, $this->visivel ); - $editou = $obj->edita(); - if( $editou ) - { - //--------------EDITA MODULO--------------// - $obj = new clsPmieducarTurmaModulo(); - $excluiu = $obj->excluirTodos($this->cod_turma); - if ( $excluiu ) - { - foreach ( $this->turma_modulo AS $campo ) - { - $campo["data_inicio_"] = dataToBanco($campo["data_inicio_"]); - $campo["data_fim_"] = dataToBanco($campo["data_fim_"]); - - $obj = new clsPmieducarTurmaModulo( $this->cod_turma, $campo["ref_cod_modulo_"], $campo["sequencial_"], $campo["data_inicio_"], $campo["data_fim_"] ); - $cadastrou1 = $obj->cadastra(); - if( !$cadastrou1 ) - { - $this->mensagem = "Edição não realizada.
"; - echo ""; - return false; - } - } - } - //--------------FIM EDITA MODULO--------------// - - //-----------------------EDITA DIA SEMANA------------------------// - $obj = new clsPmieducarTurmaDiaSemana( null, $this->cod_turma ); - $excluiu = $obj->excluirTodos(); - if ( $excluiu ) - { - foreach ( $this->turma_dia_semana AS $campo ) - { - $obj = new clsPmieducarTurmaDiaSemana( $campo["dia_semana_"], $this->cod_turma, $campo["hora_inicial_"], $campo["hora_final_"] ); - $cadastrou2 = $obj->cadastra(); - if ( !$cadastrou2 ) - { - $this->mensagem = "Edição não realizada.
"; - echo ""; - return false; - } - } - } - //-----------------------FIM EDITA DIA SEMANA------------------------// - } - else - { - $this->mensagem = "Edição não realizada.
"; - echo ""; - return false; - } - } - else - { - echo ""; - $this->mensagem = "Edição não realizada.
"; - return false; - } - } // segue o padrao do curso - else if ($this->padrao_ano_escolar == 1) - { - $obj = new clsPmieducarTurma( $this->cod_turma, $this->pessoa_logada, null, $this->ref_ref_cod_serie, $this->ref_cod_escola, $this->ref_cod_infra_predio_comodo, $this->nm_turma, $this->sgl_turma, $this->max_aluno, $this->multiseriada, null, null, 1, $this->ref_cod_turma_tipo, $this->hora_inicial, $this->hora_final, $this->hora_inicio_intervalo, $this->hora_fim_intervalo,$this->ref_cod_regente,$this->ref_cod_instituicao_regente,$this->ref_cod_instituicao,$this->ref_cod_curso, $this->ref_ref_cod_serie_mult,$this->ref_cod_escola, $this->visivel ); - $editou = $obj->edita(); - } - - if( $editou ) - { - $this->mensagem .= "Edição efetuada com sucesso.
"; - header( "Location: educar_turma_lst.php" ); - die(); - return true; - } - else - { - $this->mensagem = "Edição não realizada.
"; - echo ""; - return false; - } - } - - function Excluir() - { - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - - $obj = new clsPmieducarTurma( $this->cod_turma, $this->pessoa_logada, null,null,null,null,null,null,null,null,null,null, 0); - $excluiu = $obj->excluir(); - if( $excluiu ) - { - $obj = new clsPmieducarTurmaModulo(); - $excluiu1 = $obj->excluirTodos($this->cod_turma); - if ( $excluiu1 ) - { - $obj = new clsPmieducarTurmaDiaSemana( null, $this->cod_turma ); - $excluiu2 = $obj->excluirTodos(); - if ( $excluiu2 ) - { - $this->mensagem .= "Exclusão efetuada com sucesso.
"; - header( "Location: educar_turma_lst.php" ); - die(); - return true; - } - else - { - $this->mensagem = "Exclusão não realizada.
"; - echo ""; - return false; - } - } - else - { - $this->mensagem = "Exclusão não realizada.
"; - echo ""; - return false; - } - } - - $this->mensagem = "Exclusão não realizada.
"; - echo ""; - return false; - } + var $pessoa_logada; + + var $cod_turma; + var $ref_usuario_exc; + var $ref_usuario_cad; + var $ref_ref_cod_serie; + var $ref_ref_cod_escola; + var $ref_cod_infra_predio_comodo; + var $nm_turma; + var $sgl_turma; + var $max_aluno; + var $multiseriada; + var $data_cadastro; + var $data_exclusao; + var $ativo; + var $ref_cod_turma_tipo; + var $hora_inicial; + var $hora_final; + var $hora_inicio_intervalo; + var $hora_fim_intervalo; + + var $ref_cod_instituicao; + var $ref_cod_curso; + var $ref_cod_escola; + + var $padrao_ano_escolar; + + var $ref_cod_regente; + var $ref_cod_instituicao_regente; + + var $ref_ref_cod_serie_mult; + + // Inclui módulo + var $turma_modulo; + var $incluir_modulo; + var $excluir_modulo; + + // Inclui dia da semana + var $dia_semana; + var $ds_hora_inicial; + var $ds_hora_final; + var $turma_dia_semana; + var $incluir_dia_semana; + var $excluir_dia_semana; + var $visivel; + + var $dias_da_semana = array( + '' => 'Selecione', + 1 => 'Domingo', + 2 => 'Segunda', + 3 => 'Terça', + 4 => 'Quarta', + 5 => 'Quinta', + 6 => 'Sexta', + 7 => 'Sábado' + ); + + function Inicializar() + { + $retorno = 'Novo'; + + @session_start(); + $this->pessoa_logada = $_SESSION['id_pessoa']; + @session_write_close(); + + $this->cod_turma = $_GET['cod_turma']; + + $obj_permissoes = new clsPermissoes(); + $obj_permissoes->permissao_cadastra(586, $this->pessoa_logada, 7, 'educar_turma_lst.php'); + + if (is_numeric($this->cod_turma)) { + $obj = new clsPmieducarTurma($this->cod_turma); + $registro = $obj->detalhe(); + $obj_esc = new clsPmieducarEscola($registro['ref_ref_cod_escola']); + $det_esc = $obj_esc->detalhe(); + $obj_ser = new clsPmieducarSerie($registro['ref_ref_cod_serie']); + $det_ser = $obj_ser->detalhe(); + + $this->ref_cod_escola = $det_esc['cod_escola']; + $this->ref_cod_instituicao = $det_esc['ref_cod_instituicao']; + $this->ref_cod_curso = $det_ser['ref_cod_curso']; + + $obj_curso = new clsPmieducarCurso(($this->ref_cod_curso)); + $det_curso = $obj_curso->detalhe(); + $this->padrao_ano_escolar = $det_curso['padrao_ano_escolar']; + + if ($registro) { + foreach ($registro as $campo => $val) { + $this->$campo = $val; + } + + $this->fexcluir = $obj_permissoes->permissao_excluir( + 586, $this->pessoa_logada, 7, 'educar_turma_lst.php' + ); + + $retorno = 'Editar'; + } + } + + $this->url_cancelar = $retorno == 'Editar' ? + 'educar_turma_det.php?cod_turma=' . $registro['cod_turma'] : 'educar_turma_lst.php'; + $this->nome_url_cancelar = 'Cancelar'; + + return $retorno; + } + + function Gerar() + { + if ($_POST) { + foreach ($_POST as $campo => $val) { + $this->$campo = $this->$campo ? $this->$campo : $val; + } + } + + $this->campoOculto('cod_turma', $this->cod_turma); + + // foreign keys + $obrigatorio = FALSE; + $instituicao_obrigatorio = TRUE; + $escola_curso_obrigatorio = TRUE; + $curso_obrigatorio = TRUE; + $get_escola = TRUE; + $get_escola_curso_serie = FALSE; + $sem_padrao = TRUE; + $get_curso = TRUE; + + include 'include/pmieducar/educar_campo_lista.php'; + + if ($this->ref_cod_escola) { + $this->ref_ref_cod_escola = $this->ref_cod_escola; + } + + $opcoes_serie = array('' => 'Selecione'); + + // Editar + if ($this->ref_cod_curso) { + $obj_serie = new clsPmieducarSerie(); + $obj_serie->setOrderby('nm_serie ASC'); + $lst_serie = $obj_serie->lista(NULL, NULL, NULL, $this->ref_cod_curso, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1); + + if (is_array($lst_serie) && count($lst_serie)) { + foreach ($lst_serie as $serie) { + $opcoes_serie[$serie['cod_serie']] = $serie['nm_serie']; + } + } + } + + $script = "javascript:showExpansivelIframe(520, 550, 'educar_serie_cad_pop.php?ref_ref_cod_serie=sim');"; + + if ($this->ref_cod_instituicao && $this->ref_cod_escola && $this->ref_cod_curso) { + $script = sprintf("", + $script); + } + else { + $script = sprintf("", + $script); + } + + $this->campoLista('ref_ref_cod_serie', 'Série', $opcoes_serie, $this->ref_ref_cod_serie, + '', FALSE, '', $script); + + // Infra prédio cômodo + $opcoes = array('' => 'Selecione'); + + // Editar + if ($this->ref_ref_cod_escola) { + $obj_infra_predio = new clsPmieducarInfraPredio(); + $obj_infra_predio->setOrderby('nm_predio ASC'); + $lst_infra_predio = $obj_infra_predio->lista(NULL, NULL, NULL, + $this->ref_ref_cod_escola, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1); + + if (is_array($lst_infra_predio) && count($lst_infra_predio)) { + foreach ($lst_infra_predio as $predio) { + $obj_infra_predio_comodo = new clsPmieducarInfraPredioComodo(); + $lst_infra_predio_comodo = $obj_infra_predio_comodo->lista(NULL, NULL, + NULL, NULL, $predio['cod_infra_predio'], NULL, NULL, NULL, NULL, NULL, + NULL, NULL, 1); + + if (is_array($lst_infra_predio_comodo) && count($lst_infra_predio_comodo)) { + foreach ($lst_infra_predio_comodo as $comodo) { + $opcoes[$comodo['cod_infra_predio_comodo']] = $comodo['nm_comodo']; + } + } + } + } + } + + $this->campoLista('ref_cod_infra_predio_comodo', 'Sala', $opcoes, + $this->ref_cod_infra_predio_comodo, NULL, NULL, NULL, NULL, NULL, FALSE); + + $array_servidor = array( '' => 'Selecione um servidor' ); + if ($this->ref_cod_regente) { + $obj_pessoa = new clsPessoa_($this->ref_cod_regente); + $det = $obj_pessoa->detalhe(); + $array_servidor[$this->ref_cod_regente] = $det['nome']; + } + + $this->campoListaPesq('ref_cod_regente', 'Professor/Regente', $array_servidor, + $this->ref_cod_regente, '', '', FALSE, '', '', NULL, NULL, '', TRUE, FALSE, FALSE); + + // Turma tipo + $opcoes = array('' => 'Selecione'); + + // Editar + if ($this->ref_cod_instituicao) { + $objTemp = new clsPmieducarTurmaTipo(); + $objTemp->setOrderby('nm_tipo ASC'); + $lista = $objTemp->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, 1, $this->ref_cod_instituicao); + + if (is_array($lista) && count($lista)) { + foreach ($lista as $registro) { + $opcoes[$registro['cod_turma_tipo']] = $registro['nm_tipo']; + } + } + } + + $script = "javascript:showExpansivelIframe(520, 170, 'educar_turma_tipo_cad_pop.php');"; + + if ($this->ref_cod_instituicao && $this->ref_cod_escola && $this->ref_cod_curso) { + $script = sprintf("", + $script); + } + else { + $script = sprintf("", + $script); + } + + $this->campoLista('ref_cod_turma_tipo', 'Tipo de Turma', $opcoes, + $this->ref_cod_turma_tipo, '', FALSE, '', $script); + + $this->campoTexto('nm_turma', 'Turma', $this->nm_turma, 30, 255, TRUE); + + $this->campoTexto('sgl_turma', 'Sigla', $this->sgl_turma, 15, 15, FALSE); + + $this->campoNumero('max_aluno', 'Máximo de Alunos', $this->max_aluno, 3, 3, TRUE); + + $this->campoCheck('visivel', 'Ativo', dbBool($this->visivel)); + + $this->campoCheck('multiseriada', 'Multi-Seriada', $this->multiseriada, '', + FALSE, FALSE); + + $this->campoLista('ref_ref_cod_serie_mult','Série', array('' => 'Selecione'), + '', '', FALSE, '', '', '', FALSE); + + $this->campoOculto('ref_ref_cod_serie_mult_',$this->ref_ref_cod_serie_mult); + + $this->campoQuebra2(); + + // hora + $this->campoHora('hora_inicial', 'Hora Inicial', $this->hora_inicial, FALSE); + + $this->campoHora('hora_final', 'Hora Final', $this->hora_final, FALSE); + + $this->campoHora('hora_inicio_intervalo', 'Hora Início Intervalo', + $this->hora_inicio_intervalo, FALSE); + + $this->campoHora( 'hora_fim_intervalo', 'Hora Fim Intervalo', $this->hora_fim_intervalo, FALSE); + + // Inclui módulo + $this->campoQuebra(); + + if ($_POST['turma_modulo']) { + $this->turma_modulo = unserialize(urldecode($_POST['turma_modulo'])); + } + + $qtd_modulo = count($this->turma_modulo) == 0 ? 1 : (count($this->turma_modulo) + 1); + + if (is_numeric($this->cod_turma) && !$_POST) { + $obj = new clsPmieducarTurmaModulo(); + $registros = $obj->lista($this->cod_turma); + + if ($registros) { + foreach ($registros as $campo) { + $this->turma_modulo[$campo[$qtd_modulo]]['sequencial_'] = $campo['sequencial']; + $this->turma_modulo[$campo[$qtd_modulo]]['ref_cod_modulo_'] = $campo['ref_cod_modulo']; + $this->turma_modulo[$campo[$qtd_modulo]]['data_inicio_'] = dataFromPgToBr($campo['data_inicio']); + $this->turma_modulo[$campo[$qtd_modulo]]['data_fim_'] = dataFromPgToBr($campo['data_fim']); + $qtd_modulo++; + } + } + } + + if ($_POST["ref_cod_modulo"] && $_POST["data_inicio"] && $_POST["data_fim"]) { + $this->turma_modulo[$qtd_modulo]["sequencial_"] = $qtd_modulo; + $this->turma_modulo[$qtd_modulo]["ref_cod_modulo_"] = $_POST["ref_cod_modulo"]; + $this->turma_modulo[$qtd_modulo]["data_inicio_"] = $_POST["data_inicio"]; + $this->turma_modulo[$qtd_modulo]["data_fim_"] = $_POST["data_fim"]; + $qtd_modulo++; + + unset($this->ref_cod_modulo); + unset($this->data_inicio); + unset($this->data_fim); + } + + $this->campoOculto("excluir_modulo", ""); + + $qtd_modulo = 1; + + unset($aux); + + if ($this->turma_modulo) { + foreach ($this->turma_modulo as $campo) { + if ($this->excluir_modulo == $campo['sequencial_']) { + $this->turma_modulo[$campo['sequencial']] = NULL; + $this->excluir_modulo = NULL; + } + else { + $obj_modulo = new clsPmieducarModulo($campo['ref_cod_modulo_']); + $det_modulo = $obj_modulo->detalhe(); + $nm_tipo_modulo = $det_modulo['nm_tipo']; + + $this->campoTextoInv('ref_cod_modulo_' . $campo['sequencial_'], '', + $nm_tipo_modulo, 30, 255, FALSE, FALSE, TRUE, '', '', '', '', 'ref_cod_modulo'); + + $this->campoTextoInv('data_inicio_' . $campo['sequencial_'], '', + $campo['data_inicio_'], 10, 10, FALSE, FALSE, TRUE, '', '', '', '', ''); + + $this->campoTextoInv('data_fim_' . $campo['sequencial_'], '', $campo['data_fim_'], + 10, 10, FALSE, FALSE, FALSE, '', + "__nome}.submit();\">", + '', '', ''); + + $aux[$qtd_modulo]['sequencial_'] = $qtd_modulo; + $aux[$qtd_modulo]['ref_cod_modulo_'] = $campo['ref_cod_modulo_']; + $aux[$qtd_modulo]['data_inicio_'] = $campo['data_inicio_']; + $aux[$qtd_modulo]['data_fim_'] = $campo['data_fim_']; + $qtd_modulo++; + } + + } + unset($this->turma_modulo); + $this->turma_modulo = $aux; + } + + $this->campoOculto('turma_modulo', serialize($this->turma_modulo)); + + // Módulo + // foreign keys + $opcoes = array('' => 'Selecione'); + + // Editar + if ($this->ref_cod_instituicao) { + $objTemp = new clsPmieducarModulo(); + $objTemp->setOrderby('nm_tipo ASC'); + $lista = $objTemp->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, 1, $this->ref_cod_instituicao); + + if (is_array($lista) && count($lista)) { + foreach ($lista as $registro) { + $opcoes[$registro['cod_modulo']] = $registro['nm_tipo']; + } + } + } + + $this->campoLista('ref_cod_modulo', 'Módulo', $opcoes, $this->ref_cod_modulo, + NULL, NULL, NULL, NULL, NULL, FALSE); + + $this->campoData('data_inicio', 'Data Início', $this->data_inicio, FALSE); + $this->campoData('data_fim', 'Data Fim', $this->data_fim, FALSE); + + $this->campoOculto('incluir_modulo', ''); + + $this->campoRotulo('bt_incluir_modulo', 'Módulo', + "adicionar" + ); + + $this->campoQuebra(); + + // Inclui dia da semana + $this->campoQuebra(); + + if ($_POST['turma_dia_semana']) { + $this->turma_dia_semana = unserialize(urldecode($_POST['turma_dia_semana'])); + } + + if (is_numeric($this->cod_turma) && !$_POST) { + $obj = new clsPmieducarTurmaDiaSemana(); + $registros = $obj->lista(NULL, $this->cod_turma); + + if ($registros) { + foreach ($registros as $campo) { + $aux['dia_semana_'] = $campo['dia_semana']; + $aux['hora_inicial_'] = $campo['hora_inicial']; + $aux['hora_final_'] = $campo['hora_final']; + + $this->turma_dia_semana[] = $aux; + } + } + } + + unset($aux); + + if ($_POST['dia_semana'] && $_POST['ds_hora_inicial'] && $_POST['ds_hora_final']) { + $aux['dia_semana_'] = $_POST['dia_semana']; + $aux['hora_inicial_'] = $_POST['ds_hora_inicial']; + $aux['hora_final_'] = $_POST['ds_hora_final']; + + $this->turma_dia_semana[] = $aux; + + unset($this->dia_semana); + unset($this->ds_hora_inicial); + unset($this->ds_hora_final); + } + + $this->campoOculto('excluir_dia_semana', ''); + unset($aux); + + if ($this->turma_dia_semana) { + foreach ($this->turma_dia_semana as $key => $dias_semana) { + if ($this->excluir_dia_semana == $dias_semana['dia_semana_']) { + unset($this->turma_dia_semana[$key]); + unset($this->excluir_dia_semana); + } + else { + $nm_dia_semana = $this->dias_da_semana[$dias_semana['dia_semana_']]; + + $this->campoTextoInv('dia_semana_' . $dias_semana['dia_semana_'], '', + $nm_dia_semana, 8, 8, FALSE, FALSE, TRUE, '', '', '', '', 'dia_semana'); + + $this->campoTextoInv('hora_inicial_' . $dias_semana['dia_semana_'], '', + $dias_semana['hora_inicial_'], 5, 5, FALSE, FALSE, TRUE, '', '', '', + '', 'ds_hora_inicial_'); + + $this->campoTextoInv('hora_final_' . $dias_semana['dia_semana_'], '', + $dias_semana['hora_final_'], 5, 5, FALSE, FALSE, FALSE, '', + "__nome}.submit();\">", + '', '', 'ds_hora_final_' + ); + + $aux['dia_semana_'] = $dias_semana['dia_semana_']; + $aux['hora_inicial_'] = $dias_semana['hora_inicial_']; + $aux['hora_final_'] = $dias_semana['hora_final_']; + } + } + } + + $this->campoOculto('turma_dia_semana', serialize($this->turma_dia_semana)); + + if (class_exists('clsPmieducarTurmaDiaSemana')) { + $opcoes = $this->dias_da_semana; + } + else { + echo ''; + $opcoes = array('' => 'Erro na geração'); + } + + $this->campoLista('dia_semana', 'Dia Semana', $opcoes, $this->dia_semana, NULL, + false, '', '', false, false); + + $this->campoHora('ds_hora_inicial', 'Hora Inicial', $this->ds_hora_inicial, FALSE); + + $this->campoHora('ds_hora_final', 'Hora Final', $this->ds_hora_final, FALSE); + + $this->campoOculto('incluir_dia_semana', ''); + + $this->campoRotulo('bt_incluir_dia_semana', 'Dia Semana', + "adicionar" + ); + + $this->campoQuebra(); + + $this->campoOculto('padrao_ano_escolar', $this->padrao_ano_escolar); + + $this->acao_enviar = 'valida()'; + } + + function Novo() + { + @session_start(); + $this->pessoa_logada = $_SESSION['id_pessoa']; + @session_write_close(); + + $this->ref_cod_instituicao_regente = $this->ref_cod_instituicao; + + if ($this->multiseriada == 'on') { + $this->multiseriada = 1; + } + else { + $this->multiseriada = 0; + } + + if ($this->visivel == 'on') { + $this->visivel = TRUE; + } + else { + $this->visivel = FALSE; + } + + // Não segue o padrao do curso + if ($this->padrao_ano_escolar == 0) { + $this->turma_modulo = unserialize(urldecode($this->turma_modulo)); + $this->turma_dia_semana = unserialize(urldecode($this->turma_dia_semana)); + + if ($this->turma_modulo && $this->turma_dia_semana) { + $obj = new clsPmieducarTurma(NULL, NULL, $this->pessoa_logada, + $this->ref_ref_cod_serie, $this->ref_cod_escola, + $this->ref_cod_infra_predio_comodo, $this->nm_turma, $this->sgl_turma, + $this->max_aluno, $this->multiseriada, NULL, NULL, 1, + $this->ref_cod_turma_tipo, NULL, NULL, NULL, NULL, $this->ref_cod_regente, + $this->ref_cod_instituicao_regente, $this->ref_cod_instituicao, + $this->ref_cod_curso, $this->ref_ref_cod_serie_mult, $this->ref_cod_escola, + $this->visivel); + + $cadastrou = $obj->cadastra(); + + if ($cadastrou) { + // Cadastra módulo + foreach ($this->turma_modulo as $campo) { + $campo['data_inicio_'] = dataToBanco($campo['data_inicio_']); + $campo['data_fim_'] = dataToBanco($campo['data_fim_']); + + $obj = new clsPmieducarTurmaModulo($cadastrou, $campo['ref_cod_modulo_'], + $campo['sequencial_'], $campo['data_inicio_'], $campo['data_fim_']); + + $cadastrou1 = $obj->cadastra(); + + if (!$cadastrou1) { + $this->mensagem = 'Cadastro não realizado.'; + echo ""; + + return FALSE; + } + } + + // Cadastra dia semana + foreach ($this->turma_dia_semana as $campo) { + $obj = new clsPmieducarTurmaDiaSemana($campo["dia_semana_"], + $cadastrou, $campo["hora_inicial_"], $campo["hora_final_"]); + + $cadastrou2 = $obj->cadastra(); + + if (!$cadastrou2) { + $this->mensagem = 'Cadastro não realizado.'; + echo ""; + + return FALSE; + } + } + + $this->mensagem .= 'Cadastro efetuado com sucesso.'; + header('Location: educar_turma_lst.php'); + + die(); + } + + $this->mensagem = 'Cadastro não realizado.'; + echo ""; + + return FALSE; + } + + echo ''; + $this->mensagem = "Cadastro não realizado."; + + return FALSE; + } + + // Segue o padrão do ano escolar + elseif ($this->padrao_ano_escolar == 1) { + $obj = new clsPmieducarTurma(null, null, $this->pessoa_logada, + $this->ref_ref_cod_serie, $this->ref_cod_escola, + $this->ref_cod_infra_predio_comodo, $this->nm_turma, $this->sgl_turma, + $this->max_aluno, $this->multiseriada, null, null, 1, + $this->ref_cod_turma_tipo, $this->hora_inicial, $this->hora_final, + $this->hora_inicio_intervalo, $this->hora_fim_intervalo, + $this->ref_cod_regente, $this->ref_cod_instituicao_regente, + $this->ref_cod_instituicao, $this->ref_cod_curso, + $this->ref_ref_cod_serie_mult, $this->ref_cod_escola, $this->visivel); + + $cadastrou = $obj->cadastra(); + + if ($cadastrou) { + $this->mensagem .= 'Cadastro efetuado com sucesso.'; + header('Location: educar_turma_lst.php'); + die(); + } + + $this->mensagem = 'Cadastro não realizado.'; + echo ""; + + return FALSE; + } + } + + function Editar() + { + @session_start(); + $this->pessoa_logada = $_SESSION['id_pessoa']; + @session_write_close(); + + $this->ref_cod_instituicao_regente = $this->ref_cod_instituicao; + + if ($this->multiseriada == 'on') { + $this->multiseriada = 1; + } + else { + $this->multiseriada = 0; + } + + if ($this->visivel == 'on') { + $this->visivel = TRUE; + } + else { + $this->visivel = FALSE; + } + + // Não segue o padrão do curso + if ($this->padrao_ano_escolar == 0) { + $this->turma_modulo = unserialize(urldecode($this->turma_modulo)); + $this->turma_dia_semana = unserialize(urldecode($this->turma_dia_semana)); + + if ($this->turma_modulo && $this->turma_dia_semana) { + $obj = new clsPmieducarTurma($this->cod_turma, $this->pessoa_logada, NULL, + $this->ref_ref_cod_serie, $this->ref_cod_escola, + $this->ref_cod_infra_predio_comodo, $this->nm_turma, $this->sgl_turma, + $this->max_aluno, $this->multiseriada, NULL, NULL, 1, + $this->ref_cod_turma_tipo, NULL, NULL, NULL, NULL, $this->ref_cod_regente, + $this->ref_cod_instituicao_regente, $this->ref_cod_instituicao, + $this->ref_cod_curso, $this->ref_ref_cod_serie_mult, $this->ref_cod_escola, + $this->visivel); + + $editou = $obj->edita(); + + if ($editou) { + $obj = new clsPmieducarTurmaModulo(); + $excluiu = $obj->excluirTodos($this->cod_turma); + + if ($excluiu) { + foreach ($this->turma_modulo as $campo) { + $campo['data_inicio_'] = dataToBanco($campo['data_inicio_']); + $campo['data_fim_'] = dataToBanco($campo['data_fim_']); + + $obj = new clsPmieducarTurmaModulo($this->cod_turma, + $campo['ref_cod_modulo_'], $campo['sequencial_'], + $campo['data_inicio_'], $campo['data_fim_']); + + $cadastrou1 = $obj->cadastra(); + if (!$cadastrou1) { + $this->mensagem = 'Edição não realizada.'; + echo ""; + + return FALSE; + } + } + } + + // Edita o dia da semana + $obj = new clsPmieducarTurmaDiaSemana(NULL, $this->cod_turma); + $excluiu = $obj->excluirTodos(); + + if ($excluiu) { + foreach ($this->turma_dia_semana as $campo) { + $obj = new clsPmieducarTurmaDiaSemana($campo["dia_semana_"], + $this->cod_turma, $campo["hora_inicial_"], $campo["hora_final_"]); + + $cadastrou2 = $obj->cadastra(); + + if (!$cadastrou2) { + $this->mensagem = 'Edição não realizada.'; + echo ""; + + return FALSE; + } + } + } + } + else { + $this->mensagem = 'Edição não realizada.'; + echo ""; + + return FALSE; + } + } + else { + echo ''; + $this->mensagem = 'Edição não realizada.'; + + return FALSE; + } + } + + // Segue o padrão do curso + elseif ($this->padrao_ano_escolar == 1) { + $obj = new clsPmieducarTurma($this->cod_turma, $this->pessoa_logada, NULL, + $this->ref_ref_cod_serie, $this->ref_cod_escola, $this->ref_cod_infra_predio_comodo, + $this->nm_turma, $this->sgl_turma, $this->max_aluno, $this->multiseriada, + NULL, NULL, 1, $this->ref_cod_turma_tipo, $this->hora_inicial, $this->hora_final, + $this->hora_inicio_intervalo, $this->hora_fim_intervalo, $this->ref_cod_regente, + $this->ref_cod_instituicao_regente, $this->ref_cod_instituicao, + $this->ref_cod_curso, $this->ref_ref_cod_serie_mult, $this->ref_cod_escola, + $this->visivel); + + $editou = $obj->edita(); + } + + if ($editou) { + $this->mensagem .= 'Edição efetuada com sucesso.'; + header('Location: educar_turma_lst.php'); + die(); + } + else { + $this->mensagem = 'Edição não realizada.'; + echo ""; + + return FALSE; + } + } + + function Excluir() + { + @session_start(); + $this->pessoa_logada = $_SESSION['id_pessoa']; + @session_write_close(); + + $obj = new clsPmieducarTurma($this->cod_turma, $this->pessoa_logada, null, + null, null, null, null, null, null, null, null, null, 0); + + $excluiu = $obj->excluir(); + + if ($excluiu) { + $obj = new clsPmieducarTurmaModulo(); + $excluiu1 = $obj->excluirTodos($this->cod_turma); + + if ($excluiu1) { + $obj = new clsPmieducarTurmaDiaSemana(NULL, $this->cod_turma); + $excluiu2 = $obj->excluirTodos(); + + if ($excluiu2) { + $this->mensagem .= 'Exclusão efetuada com sucesso.'; + header('Location: educar_turma_lst.php'); + die(); + } + else { + $this->mensagem = 'Exclusão não realizada.'; + echo ""; + + return FALSE; + } + } + else + { + $this->mensagem = 'Exclusão não realizada.'; + echo ""; + + return FALSE; + } + } + + $this->mensagem = 'Exclusão não realizada.'; + echo ""; + + return FALSE; + } } -// cria uma extensao da classe base +// Instancia objeto de página $pagina = new clsIndexBase(); -// cria o conteudo + +// Instancia objeto de conteúdo $miolo = new indice(); -// adiciona o conteudo na clsBase -$pagina->addForm( $miolo ); -// gera o html + +// Atribui o conteúdo à página +$pagina->addForm($miolo); + +// Gera o código HTML $pagina->MakeAll(); ?> - \ No newline at end of file -- libgit2 0.21.2