[QSL Labels] Now prints specified number of QSOs on label

pull/2199/head
Andreas 2023-06-05 16:53:06 +02:00
rodzic bb22812a89
commit d56f4474dc
2 zmienionych plików z 85 dodań i 19 usunięć

Wyświetl plik

@ -117,8 +117,7 @@ class Labels extends CI_Controller {
'width' => $label->width, 'width' => $label->width,
'height' => $label->height, 'height' => $label->height,
'font-size' => $label->font_size 'font-size' => $label->font_size
) ));
);
} else { } else {
// Standard format // Standard format
$pdf = new PDF_Label('3422'); $pdf = new PDF_Label('3422');
@ -128,12 +127,23 @@ class Labels extends CI_Controller {
redirect('labels'); redirect('labels');
} }
$pdf->AddPage(); $pdf->AddPage();
if ($result->num_rows() > 0) { if ($result->num_rows() > 0) {
// output data of each row if ($numberofqsos == 1) {
foreach($result->result() as $qso) { $this->makeOneQsoLabel($result->result(), $pdf);
} else {
$this->makeMultiQsoLabel($result->result(), $pdf, $label->qsos);
}
} else {
$this->session->set_flashdata('message', '0 QSOs found for print!');
redirect('labels');
}
$pdf->Output();
}
function makeOneQsoLabel($qsos, $pdf) {
foreach($qsos as $qso) {
$time = strtotime($qso->COL_TIME_ON); $time = strtotime($qso->COL_TIME_ON);
$myFormatForView = date("d/m/Y H:i", $time); $myFormatForView = date("d/m/Y H:i", $time);
if($qso->COL_SAT_NAME != "") { if($qso->COL_SAT_NAME != "") {
@ -144,11 +154,67 @@ class Labels extends CI_Controller {
$pdf->Add_Label($text); $pdf->Add_Label($text);
} }
} else {
echo "0 results";
} }
$pdf->Output(); function makeMultiQsoLabel($qsos, $pdf, $numberofqsos) {
$text = '';
$current_callsign = '';
$qso_data = [];
foreach($qsos as $qso) {
if ($qso->COL_CALL !== $current_callsign) {
if (!empty($qso_data)) {
$this->makeLabel($pdf, $current_callsign, $qso_data, $numberofqsos);
$qso_data = [];
}
$current_callsign = $qso->COL_CALL;
}
$qso_data[] = [
'time' => $qso->COL_TIME_ON,
'band' => $qso->COL_BAND,
'mode' => $qso->COL_MODE,
'rst' => $qso->COL_RST_SENT,
'mygrid' => $qso->station_gridsquare,
'sat' => $qso->COL_SAT_NAME,
'sat_mode' => $qso->COL_SAT_MODE,
];
}
if (!empty($qso_data)) {
$this->makeLabel($pdf, $current_callsign, $qso_data, $numberofqsos);
}
}
function makeLabel($pdf, $current_callsign, $qso_data, $numberofqsos) {
$text = 'To: ' . $current_callsign . "\n\n";
$count = 0;
$qsotext = '';
foreach ($qso_data as $key => $qso) {
$time = strtotime($qso['time']);
$myFormatForView = date("d/m/Y H:i", $time);
if($qso['sat'] != "") {
$qsotext .= sprintf("%s %s %s %s\n", $myFormatForView, 'on '.$qso['band'].' 2x'.$qso['mode'].' RST '.$qso['rst'].'', 'Satellite: '.$qso['sat'].' Mode: '.strtoupper($qso['sat_mode']).' ', '');
} else {
$qsotext .= sprintf("%s %s\n", $myFormatForView, 'on '.$qso['band'].' 2x'.$qso['mode'].' RST '.$qso['rst']);
}
$count++;
if ($count == $numberofqsos) {
$text .= $qsotext;
$text .= "\n" . 'Thanks for QSOs.';
$pdf->Add_Label($text);
$text = 'To: ' . $current_callsign . "\n\n";
$count = 0;
$qsotext = '';
}
unset($qso_data[$key]);
}
if ($qsotext != '') {
$text .= $qsotext;
$text .= "\n" . 'Thanks for QSOs.';
$pdf->Add_Label($text);
}
} }

Wyświetl plik

@ -95,8 +95,8 @@
echo '<td>' . $qso->station_profile_name . '</td>'; echo '<td>' . $qso->station_profile_name . '</td>';
echo '<td>' . $qso->station_gridsquare . '</td>'; echo '<td>' . $qso->station_gridsquare . '</td>';
echo '<td>' . $qso->count . '</td>'; echo '<td>' . $qso->count . '</td>';
echo '<td><a href="'. site_url('qslprint') .'" class="btn btn-outline-info btn-sm"><i class="fas fa-search"></i></a></td>'; echo '<td><a href="'. site_url('qslprint') . '" class="btn btn-outline-info btn-sm"><i class="fas fa-search"></i></a></td>';
echo '<td><a href="labels/print/'. $qso->station_id.'" class="btn btn-outline-success btn-sm"><i class="fas fa-print"></i></a></td>'; echo '<td><a href="'. site_url('labels/print/' . $qso->station_id) . '" class="btn btn-outline-success btn-sm"><i class="fas fa-print"></i></a></td>';
echo '</tr>'; echo '</tr>';
} ?> } ?>
</tbody> </tbody>