[Bands] Can now create new band

这个提交包含在:
Andreas 2022-09-06 19:35:27 +02:00
父节点 0366431975
当前提交 7326c7ec35
共有 4 个文件被更改,包括 50 次插入30 次删除

查看文件

@ -33,13 +33,12 @@ class Band extends CI_Controller {
$this->load->model('bands'); $this->load->model('bands');
$this->load->library('form_validation'); $this->load->library('form_validation');
$this->form_validation->set_rules('mode', 'Mode', 'required'); $this->form_validation->set_rules('band', 'Band', 'required');
$this->form_validation->set_rules('qrgmode', 'QRG-Mode', 'required');
if ($this->form_validation->run() == FALSE) if ($this->form_validation->run() == FALSE)
{ {
$data['page_title'] = "Create Mode"; $data['page_title'] = "Create Mode";
$this->load->view('mode/create', $data); $this->load->view('bands/create', $data);
} }
else else
{ {

查看文件

@ -242,6 +242,21 @@ class Bands extends CI_Model {
return true; return true;
} }
function add() {
$data = array(
'band' => xss_clean($this->input->post('band', true)),
);
$this->db->where('band', xss_clean($this->input->post('band', true)));
$result = $this->db->get('bands');
if ($result->num_rows() == 0) {
$this->db->insert('bands', $data);
}
$this->db->query("insert into bandxuser (bandid, userid, active, cq, dok, dxcc, iota, sig, sota, uscounties, was, vucc)
select bands.id, " . $this->session->userdata('user_id') . ", 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 from bands where band ='".$data['band']."' and not exists (select 1 from bandxuser where userid = " . $this->session->userdata('user_id') . " and bandid = bands.id);");
}
} }
?> ?>

查看文件

@ -0,0 +1,32 @@
<div class="container" id="create_mode">
<br>
<?php if($this->session->flashdata('message')) { ?>
<!-- Display Message -->
<div class="alert-message error">
<p><?php echo $this->session->flashdata('message'); ?></p>
</div>
<?php } ?>
<?php if($this->session->flashdata('notice')) { ?>
<div id="message" >
<?php echo $this->session->flashdata('notice'); ?>
</div>
<?php } ?>
<?php $this->load->helper('form'); ?>
<?php echo validation_errors(); ?>
<form>
<div class="form-group">
<label for="bandInput">Band</label>
<input type="text" class="form-control" name="band" id="bandInput" aria-describedby="bandInputHelp" required>
<small id="bandInputHelp" class="form-text text-muted">Band name</small>
</div>
<button type="button" onclick="createBand(this.form);" class="btn btn-primary"><i class="fas fa-plus-square"></i> Create band</button>
</form>
</div>

查看文件

@ -31,7 +31,7 @@ function createBandDialog() {
} }
function createBand(form) { function createBand(form) {
if (form.mode.value != '') { if (form.band.value != '') {
$.ajax({ $.ajax({
url: base_url + 'index.php/band/create', url: base_url + 'index.php/band/create',
type: 'post', type: 'post',
@ -45,32 +45,6 @@ function createBand(form) {
} }
} }
function deactivateBand(bandid) {
$.ajax({
url: base_url + 'index.php/band/deactivate',
type: 'post',
data: { 'id': bandid },
success: function (html) {
$(".mode_" + modeid).text('not active');
$('.btn_' + modeid).html('Activate');
$('.btn_' + modeid).attr('onclick', 'activateMode(' + modeid + ')')
}
});
}
function activateBand(bandid) {
$.ajax({
url: base_url + 'index.php/band/activate',
type: 'post',
data: { 'id': bandid },
success: function (html) {
$('.mode_' + modeid).text('active');
$('.btn_' + modeid).html('Deactivate');
$('.btn_' + modeid).attr('onclick', 'deactivateMode(' + modeid + ')')
}
});
}
function deleteBand(id, band) { function deleteBand(id, band) {
BootstrapDialog.confirm({ BootstrapDialog.confirm({
title: 'DANGER', title: 'DANGER',