[Bands] Added master checkbox for award

pull/1642/head
Andreas 2022-10-06 11:41:01 +02:00
rodzic 40b5746e48
commit ccacc244db
4 zmienionych plików z 88 dodań i 10 usunięć

Wyświetl plik

@ -137,4 +137,16 @@ class Band extends CI_Controller {
echo json_encode(array('message' => 'OK'));
return;
}
public function saveBandAward() {
$award = $this->security->xss_clean($this->input->post('award'));
$status = $this->security->xss_clean($this->input->post('status'));
$this->load->model('bands');
$this->bands->saveBandAward($award, $status);
header('Content-Type: application/json');
echo json_encode(array('message' => 'OK'));
return;
}
}

Wyświetl plik

@ -260,6 +260,18 @@ class Bands extends CI_Model {
$this->db->update('bandxuser', $data);
return true;
}
function saveBandAward($award, $status) {
$data = array(
$award => $status == "true" ? '1' : '0',
);
$this->db->where('bandxuser.userid', $this->session->userdata('user_id'));
$this->db->update('bandxuser', $data);
return true;
}

Wyświetl plik

@ -1,3 +1,15 @@
<?php
$cq = 0;
$dok = 0;
$dxcc = 0;
$iota = 0;
$sig = 0;
$sota = 0;
$uscounties = 0;
$vucc = 0;
$was = 0;
$wwff = 0;
?>
<div class="container">
<br>
@ -51,16 +63,16 @@
<tr>
<td class='band_<?php echo $band->id ?>'><input type="checkbox" <?php if ($band->active == 1) {echo 'checked';}?>></td>
<td><?php echo $band->band;?></td>
<td class='cq_<?php echo $band->id ?>'><input type="checkbox" <?php if ($band->cq == 1) {echo 'checked';}?>></td>
<td class='dok_<?php echo $band->id ?>'><input type="checkbox" <?php if ($band->dok == 1) {echo 'checked';}?>></td>
<td class='dxcc_<?php echo $band->id ?>'><input type="checkbox" <?php if ($band->dxcc == 1) {echo 'checked';}?>></td>
<td class='iota_<?php echo $band->id ?>'><input type="checkbox" <?php if ($band->iota == 1) {echo 'checked';}?>></td>
<td class='sig_<?php echo $band->id ?>'><input type="checkbox" <?php if ($band->sig == 1) {echo 'checked';}?>></td>
<td class='sota_<?php echo $band->id ?>'><input type="checkbox" <?php if ($band->sota == 1) {echo 'checked';}?>></td>
<td class='uscounties_<?php echo $band->id ?>'><input type="checkbox" <?php if ($band->uscounties == 1) {echo 'checked';}?>></td>
<td class='vucc_<?php echo $band->id ?>'><input type="checkbox" <?php if ($band->vucc == 1) {echo 'checked';}?>></td>
<td class='was_<?php echo $band->id ?>'><input type="checkbox" <?php if ($band->was == 1) {echo 'checked';}?>></td>
<td class='wwff_<?php echo $band->id ?>'><input type="checkbox" <?php if ($band->wwff == 1) {echo 'checked';}?>></td>
<td class='cq_<?php echo $band->id ?>'><input type="checkbox" <?php if ($band->cq == 1) {echo 'checked'; $cq++;}?>></td>
<td class='dok_<?php echo $band->id ?>'><input type="checkbox" <?php if ($band->dok == 1) {echo 'checked'; $dok++;}?>></td>
<td class='dxcc_<?php echo $band->id ?>'><input type="checkbox" <?php if ($band->dxcc == 1) {echo 'checked'; $dxcc++;}?>></td>
<td class='iota_<?php echo $band->id ?>'><input type="checkbox" <?php if ($band->iota == 1) {echo 'checked'; $iota++;}?>></td>
<td class='sig_<?php echo $band->id ?>'><input type="checkbox" <?php if ($band->sig == 1) {echo 'checked'; $sig++;}?>></td>
<td class='sota_<?php echo $band->id ?>'><input type="checkbox" <?php if ($band->sota == 1) {echo 'checked'; $sota++;}?>></td>
<td class='uscounties_<?php echo $band->id ?>'><input type="checkbox" <?php if ($band->uscounties == 1) {echo 'checked'; $uscounties++;}?>></td>
<td class='vucc_<?php echo $band->id ?>'><input type="checkbox" <?php if ($band->vucc == 1) {echo 'checked'; $vucc++;}?>></td>
<td class='was_<?php echo $band->id ?>'><input type="checkbox" <?php if ($band->was == 1) {echo 'checked'; $was++;}?>></td>
<td class='wwff_<?php echo $band->id ?>'><input type="checkbox" <?php if ($band->wwff == 1) {echo 'checked'; $wwff++;}?>></td>
<td><?php echo $band->bandgroup;?></td>
<td><?php echo $band->ssb;?></td>
<td><?php echo $band->data;?></td>
@ -75,6 +87,26 @@
<?php } ?>
</tbody>
<tfoot>
<th></th>
<th></th>
<th class="master_cq"><input type="checkbox" <?php if ($cq > 0) echo 'checked';?>></th>
<th class="master_dok"><input type="checkbox" <?php if ($dok > 0) echo 'checked';?>></th>
<th class="master_dxcc"><input type="checkbox" <?php if ($dxcc > 0) echo 'checked';?>></th>
<th class="master_iota"><input type="checkbox" <?php if ($iota > 0) echo 'checked';?>></th>
<th class="master_sig"><input type="checkbox" <?php if ($sig > 0) echo 'checked';?>></th>
<th class="master_sota"><input type="checkbox" <?php if ($sota > 0) echo 'checked';?>></th>
<th class="master_uscounties"><input type="checkbox" <?php if ($uscounties > 0) echo 'checked';?>></th>
<th class="master_vucc"><input type="checkbox" <?php if ($vucc > 0) echo 'checked';?>></th>
<th class="master_was"><input type="checkbox" <?php if ($was > 0) echo 'checked';?>></th>
<th class="master_wwff"><input type="checkbox" <?php if ($wwff > 0) echo 'checked';?>></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tfoot>
<table>
</div>
<br/>

Wyświetl plik

@ -4,6 +4,28 @@ $('.bandtable').on('click', 'input[type="checkbox"]', function() {
saveBand(clickedbandid);
});
$('.bandtable tfoot').on('click', 'input[type="checkbox"]', function() {
var clickedaward = $(this).closest('th').attr("class");
var status = $(this).is(":checked");
clickedaward = clickedaward.replace('master_', '');
$('[class^='+clickedaward+'_] input[type="checkbox').each(function() {
$(this).prop( "checked", status );
});
saveBandAward(clickedaward, status);
});
function saveBandAward(award, status) {
$.ajax({
url: base_url + 'index.php/band/saveBandAward',
type: 'post',
data: {'award': award,
'status': status,
},
success: function (html) {
}
});
}
$('.bandtable').DataTable({
"pageLength": 25,
responsive: false,