Skip to content

Commit 58cf769

Browse files
committed
Correções na exibição de horário
1 parent 101408a commit 58cf769

File tree

3 files changed

+31
-25
lines changed

3 files changed

+31
-25
lines changed

ajax/horario.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
$tem_grad = $tem_pos = false;
6161
} elseif($_tipo == 'P') {
6262
$Professor = ((isset($_POST['professor'])) && ($_POST['professor'] > 0)) ? Professor::Load(intval($_POST['professor'])) : $_Usuario->getProfessor(true);
63-
$Horario = $Professor->Monta_Horario($Periodo_Selecionado->getPeriodo());
63+
$Horario = $Professor->Monta_Horario($Periodo_Selecionado);
6464
$meu = (($_Usuario->getProfessor(false) !== null) && ($_Usuario->getProfessor()->getID() == $Professor->getID()));
6565
$nivel = null;
6666
$tem_grad = $tem_pos = false;
@@ -127,7 +127,7 @@
127127
?>
128128
<tr>
129129
<td colspan="2" style="padding: 10px 5px;"><strong>Oferecimentos:</strong></td>
130-
<td colspan="5" style="padding: 10px 5px;"><?= $Professor->getOferecimentos($Periodo_Selecionado->getPeriodo(), $nivel, true); ?></td>
130+
<td colspan="5" style="padding: 10px 5px;"><?= $Professor->getOferecimentos($Periodo_Selecionado, $nivel, true); ?></td>
131131
</tr>
132132
<?php } ?>
133133
</table>

classes/GDE/Professor.inc.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace GDE;
44

55
use Doctrine\Common\Collections\ArrayCollection;
6+
use Doctrine\Common\Collections\Criteria;
67
use Doctrine\ORM\Mapping as ORM;
78
use Doctrine\ORM\Query\ResultSetMappingBuilder;
89

@@ -115,35 +116,37 @@ public static function Nome_Unico($nome) {
115116
}
116117

117118
/**
118-
* @param null|string $periodo
119+
* @param null|Periodo $Periodo
119120
* @param bool $formatado
120121
* @param bool $links
121-
* @return string
122+
* @return ArrayCollection|Oferecimento[]|string
122123
*/
123-
public function getOferecimentos($periodo = null, $formatado = false, $links = true) {
124-
if($periodo == null) {
124+
public function getOferecimentos(Periodo $Periodo = null, $formatado = false, $links = true) {
125+
if($Periodo === null) {
125126
$Oferecimentos = parent::getOferecimentos();
126127
} else {
127-
$criteria = Criteria::create()->where(Criteria::expr()->eq("id_periodo", $periodo));
128+
$criteria = Criteria::create()->where(Criteria::expr()->eq("periodo", $Periodo));
128129
$Oferecimentos = parent::getOferecimentos()->matching($criteria);
129130
}
130131
if($formatado === false)
131132
return $Oferecimentos;
132133
else {
133134
$lista = array();
134135
foreach($Oferecimentos as $Oferecimento)
135-
$lista[] = ($links) ? "<a href=\"".CONFIG_URL."oferecimento/".$Oferecimento->getID()."/\" title=\"".$Oferecimento->getDisciplina(true)->getNome(true)."\">".$Oferecimento->getSigla().$Oferecimento->getTurma(true)."</a> (".$Oferecimento->getDisciplina(true)->getCreditos(true).")" : $Oferecimento->getSigla(true).$Oferecimento->getTurma(true)." (".$Oferecimento->getDisciplina(true)->getCreditos(true).")";
136+
$lista[] = ($links)
137+
? "<a href=\"".CONFIG_URL."oferecimento/".$Oferecimento->getID()."/\" title=\"".$Oferecimento->getDisciplina(true)->getNome(true)."\">".$Oferecimento->getSigla().$Oferecimento->getTurma(true)."</a> (".$Oferecimento->getDisciplina(true)->getCreditos(true).")"
138+
: $Oferecimento->getSigla(true).$Oferecimento->getTurma(true)." (".$Oferecimento->getDisciplina(true)->getCreditos(true).")";
136139
return (count($lista) > 0) ? implode(", ", $lista) : '-';
137140
}
138141
}
139142

140143
/**
141-
* @param null $periodo
144+
* @param null|Periodo $Periodo
142145
* @return array
143146
*/
144-
public function Monta_Horario($periodo = null) {
147+
public function Monta_Horario(Periodo $Periodo = null) {
145148
$Lista = array();
146-
foreach($this->getOferecimentos($periodo) as $Oferecimento)
149+
foreach($this->getOferecimentos($Periodo) as $Oferecimento)
147150
foreach($Oferecimento->getDimensoes() as $Dimensao)
148151
$Lista[$Dimensao->getDia()][$Dimensao->getHorario()][] = array($Oferecimento, $Dimensao->getSala(true)->getNome());
149152
return $Lista;
@@ -157,7 +160,7 @@ public function Monta_Horario($periodo = null) {
157160
* @param null $total
158161
* @param int $limit
159162
* @param int $start
160-
* @return ArrayCollection|Professor[]
163+
* @return Professor[]
161164
*/
162165
public static function Por_Nome($nome, $ordem = null, &$total = null, $limit = -1, $start = -1) {
163166
$param = array(1 => "%".str_replace(' ', '%', $nome)."%");

classes/GDE/Usuario.inc.php

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,26 +1542,29 @@ public function Formata_Horario($Horario, $dia, $hora, $meu, Periodo $Periodo =
15421542
return "-";
15431543
$formatado = array();
15441544
$i = 0;
1545-
foreach($Horario[$dia][$hora] as $Oferecimento) {
1546-
$strong_oferecimento = ((!$meu) && ($Periodo !== null) && ($this->Cursando($Oferecimento[0])));
1547-
$strong_sala = ((!$meu) && ($Periodo !== null) && ($this->Tem_Dimensao(array($Oferecimento[1], $dia, $hora), $Periodo)));
1545+
foreach($Horario[$dia][$hora] as $dados) {
1546+
list($Oferecimento, $sala) = $dados;
1547+
$strong_oferecimento = ((!$meu) && ($Periodo !== null) && ($this->Cursando($Oferecimento)));
1548+
$strong_sala = ((!$meu) && ($Periodo !== null) && ($this->Tem_Dimensao(array($sala, $dia, $hora), $Periodo)));
15481549
$formatado[$i] = (
15491550
($links)
1550-
? "<a href=\"".CONFIG_URL."oferecimento/".$Oferecimento[0]->getID()."/\" title=\"".$Oferecimento[0]->getDisciplina()->getNome()."\">"
1551+
? "<a href=\"".CONFIG_URL."oferecimento/".$Oferecimento->getID()."/\" title=\"".$Oferecimento->getDisciplina()->getNome(true)."\">"
15511552
: null
15521553
).
15531554
(($strong_oferecimento) ? "<strong>" : null).
1554-
$Oferecimento[0]->getSigla().$Oferecimento[0]->getTurma().
1555+
$Oferecimento->getSigla(true).$Oferecimento->getTurma(true).
15551556
(($strong_oferecimento) ? "</strong>" : null ).
15561557
(($links) ? "</a>" : null);
1557-
if(!empty($Oferecimento[1]))
1558+
if(!empty($dados[1])) {
15581559
$formatado[$i] .= (($links)
1559-
? "/<a href=\"".CONFIG_URL."sala/".$Oferecimento[1]."/\">"
1560-
: "/").
1561-
(($strong_sala) ? "<strong>" : null).
1562-
$Oferecimento[1].
1563-
(($strong_sala) ? "</strong>" : null).
1564-
(($links) ? "</a>" : null);
1560+
? "/<a href=\"" . CONFIG_URL . "sala/" . $sala . "/\">"
1561+
: "/") .
1562+
(($strong_sala) ? "<strong>" : null) .
1563+
$sala .
1564+
(($strong_sala) ? "</strong>" : null) .
1565+
(($links) ? "</a>" : null);
1566+
}
1567+
$i++;
15651568
}
15661569
return implode("<br />", $formatado);
15671570
}
@@ -1581,7 +1584,7 @@ public function Formata_Horario_Sala($Horario, $dia, $hora) {
15811584
if(isset($Horario[$dia][$hora])) {
15821585
foreach($Horario[$dia][$hora] as $Oferecimento) {
15831586
$strong = $this->Cursando($Oferecimento);
1584-
$formatado[] = "<a href=\"".CONFIG_URL."oferecimento/".$Oferecimento->getID()."/\">".(($strong) ? "<strong>" : "").$Oferecimento->getSigla().$Oferecimento->getTurma().(($strong) ? "</strong>" : "")."</a>";
1587+
$formatado[] = "<a href=\"".CONFIG_URL."oferecimento/".$Oferecimento->getID()."/\">".(($strong) ? "<strong>" : "").$Oferecimento->getSigla(true).$Oferecimento->getTurma(true).(($strong) ? "</strong>" : "")."</a>";
15851588
}
15861589
return implode("<br />", $formatado);
15871590
} else

0 commit comments

Comments
 (0)