Minha necessidade é agrupar os conceitos conforme a disciplina, segue o modelo:
Como conseguir fazer: (Não estou conseguindo agrupar em uma "disciplina", apenas. Como ficou:
<?php
function integerToRoman($integer)
{
$integer = intval($integer);
$result = '';
$lookup = array(
'M' => 1000,
'CM' => 900,
'D' => 500,
'CD' => 400,
'C' => 100,
'XC' => 90,
'L' => 50,
'XL' => 40,
'X' => 10,
'IX' => 9,
'V' => 5,
'IV' => 4,
'I' => 1
);
foreach($lookup as $roman => $value){
$matches = intval($integer/$value);
$result .= str_repeat($roman,$matches);
$integer = $integer % $value;
}
return $result;
}
?>
<div id="print">
<link rel="stylesheet" href="<?php echo base_url('assets/css/bootstrap.css'); ?>">
<script src="assets/js/jquery-1.11.0.min.js"></script>
<style>
hr {
display: block;
height: 1px;
border: 0;
border-top: 1px solid black;
margin: 1em 0;
padding: 0;
}
.mt-1 {
margin-top: 10px;
}
.border-top { border-top: 1px solid; }
.border-left { border-left: 1px solid; }
.border-right { border-right: 1px solid; }
.border-bottom { border-bottom: 1px solid; }
</style>
<?php
$class = $this->db->get_where('class', array(
'class_id' => $class_id,
))->row();
$section = $this->db->get_where('section', array(
'section_id' => $section_id,
))->row();
$teacher = $this->db->get_where('teacher', array(
'teacher_id' => $section->teacher_id,
))->row();
$students = $this->db->get_where('enroll', array(
'class_id' => $class->class_id,
'section_id' => $section->section_id,
))->result_array();
$subjects = $this->db->get_where('subject', array(
'section_id' => $section_id,
))->result_array();
$signatures = $this->db->get('signatures')->result_array();
$print = $this->db->get('print_settings')->row();
foreach($students as $student) {
$stu = $this->db->get_where('student', array(
'student_id' => $student['student_id'],
))->row();
for($i = 1; $i <= 4; $i++) {
$exam = $this->db->get_where('exam', array(
'exam_id' => $i,
))->row();
?>
<div class="row" style="margin-top: 5px;">
<div class="col-xs-12">
<div class="col-xs-2" style="margin-left: 0px; padding: 0;">
<?php
$fName = $print->logo;
$ext_pos = strrpos($fName, '.');
$ext = substr($fName, $ext_pos);
$fName = substr($fName, 0, $ext_pos);
$fName = str_replace('.', '_', $fName) . $ext;
$fName = preg_replace('/\s+/', '_', $fName);
?>
<img src="<?= base_url('/uploads/' . $fName); ?>" width="113" height="100" /> <br />
</div>
<div class="col-xs-10" style="margin-left: 0px; padding: 0; line-height: 5px;">
<p style="font-weight: 700; font-size: 1.1em;"><?= $system_name ?></p>
<p><?= $print->name ?></p>
<p>CNPJ: <?= $print->cnpj ?></p>
<p>Endereço: <?= $print->address ?></p>
<p>Bairro: <?= $print->neighborhood ?></p>
<p>Telefone: <?= $print->phone ?> Email: <?= $print->email ?></p> <br><br>
<p><b>Resolução</b>: <?= $print->resolution ?></p>
</div>
</div>
</div>
<div class="col-xs-12 mt-3">
Professor (a): <?= $teacher->name ?>
</div>
<div class="col-xs-12 mt-1">
Aluno (a): <?= $stu->name ?>
</div>
<div class="col-xs-4 mt-1">
Ano/Turma: <?= $class->name ?> / <?= $section->name ?>
</div>
<div class="col-xs-2 mt-1">
Ano Letivo: <?= $sessional_year ?>
</div>
<div class="col-xs-3 mt-1">
Bimestre: <?= integerToRoman($i) ?>
</div>
<div class="col-xs-3 mt-1">
Encerrado em: <?= $exam->comment ?>
</div>
<div class="col-xs-12">
<div class="col-xs-12 text-center">
<h4><strong><?php echo $i.'º Bimeste' ?></strong></h4>
</div>
<?php
$curType = '';
if(strpos($class->name, '1º Ano') !== false)
$curType = '1º Ano';
if(strpos($class->name, '2º Ano') !== false)
$curType = '2º Ano';
$conceitos = [];
foreach($subjects as $subject) {
array_push($conceitos, $this->db->get_where('learning_goals', array(
'type' => $curType,
'eixos' => $i.'º Bimestre',
'subject_id' => $subject['subject_id'],
))->result_array());
}
$eixos = [];
$_subjects = [];
foreach($conceitos as $conceito) {
if(in_array($conceito['eixos'], $eixos))
continue;
array_push($eixos, $conceito['eixos']);
$_descs = [];
$descs = [];
foreach($subjects as $subject) {
array_push($_descs, $this->db->get_where('learning_goals', array(
'type' => $curType,
'eixos' => $i.'º Bimestre',
'subject_id' => $subject['subject_id'],
))->result_array());
}
foreach($_descs as $_desc) {
foreach($_desc as $_des) {
array_push($descs, $_des);
}
}
foreach($descs as $key => $desc) {
$descStatus = $this->db->get_where('learning_goals_status', array(
'exam_id' => $i,
'conceito_id' => $conceito['id'],
'student_id' => $stu->student_id,
))->row();
$subject = $this->db->get_where('subject', array('subject_id' => $desc['subject_id'],
))->row();
$key++;
?>
<div class="col-xs-11 text-center">HABILIDADES QUE A CRIANÇA DEMONSTRA EM <?= $subject->name?></div>
<div class="col-xs-11 border-top border-bottom border-left border-right"><?= $desc['sys_id'] ?>. <?= $desc['description'] ?></div>
<div class="col-xs-1 border-bottom border-top border-right"> <?= $descStatus->status ?></div>
<?php
}
?>
<?php
}
?>
</div>
<div class="col-xs-12 mt-3 text-center" style="padding-left: 0; padding-right: 0;">
<div class="col-xs-6" style="margin-top: 15px">
<hr>
<p class="text-center"><strong><?= $teacher->name ?></strong><br>
Professor(a)</p>
</div>
<div class="col-xs-6" style="margin-top: 15px">
<hr>
<p class="text-center"><strong><?= $signatures[2]['name'] ?></strong><br>
<?= $signatures[2]['post'] ?></p>
</div>
<div class="col-xs-6" style="margin-top: 10px">
<hr>
<p class="text-center"><strong><?= $signatures[0]['name'] ?></strong><br>
<?= $signatures[0]['post'] ?></p>
</div>
<div class="col-xs-6" style="margin-top: 10px">
<hr>
<p class="text-center"><strong><?php echo $this->db->get_where('parent',array('parent_id'=>$stu->parent_id))->row()->name; ?></strong><br>
Responsável pelo(a) aluno(a)</p>
</div>
</div>
<?php
}
}
?>
</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
var elem = $('#print');
PrintElem(elem);
Popup(data);
});
function PrintElem(elem) {
Popup($(elem).html());
}
function Popup(data) {
var mywindow = window.open('', 'my div', 'height=400,width=600');
mywindow.document.write('<html><head><title></title>');
//mywindow.document.write('<link rel="stylesheet" href="assets/css/print.css" type="text/css" />');
mywindow.document.write('</head><body >');
//mywindow.document.write('<style>.print{border : 1px;}</style>');
mywindow.document.write(data);
mywindow.document.write('</body></html>');
mywindow.document.close(); // necessary for IE >= 10
mywindow.focus(); // necessary for IE >= 10
mywindow.print();
mywindow.close();
return true;
}
</script>