mirror of
https://github.com/magicbug/Cloudlog
synced 2024-11-22 17:52:16 +00:00
set logbook active on creation of first logbook
set station profile active on creation of first station profile disabled deletion of active logbook disabled deletion of active station profile
This commit is contained in:
parent
e044da8df0
commit
278cf3b016
@ -8,7 +8,7 @@ class Logbooks_model extends CI_Model {
|
||||
return $this->db->get('station_logbooks');
|
||||
}
|
||||
|
||||
function add() {
|
||||
function add() {
|
||||
// Create data array with field values
|
||||
$data = array(
|
||||
'user_id' => $this->session->userdata('user_id'),
|
||||
@ -16,14 +16,31 @@ class Logbooks_model extends CI_Model {
|
||||
);
|
||||
|
||||
// Insert Records
|
||||
$this->db->insert('station_logbooks', $data);
|
||||
$this->db->insert('station_logbooks', $data);
|
||||
$logbook_id = $this->db->insert_id();
|
||||
|
||||
// check if user has no active logbook yet
|
||||
if ($this->session->userdata('active_station_logbook') === null) {
|
||||
// set logbook active
|
||||
$this->set_logbook_active($logbook_id);
|
||||
|
||||
// update user session data
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('user_model');
|
||||
$CI->user_model->update_session($this->session->userdata('user_id'));
|
||||
}
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
// Clean ID
|
||||
$clean_id = $this->security->xss_clean($id);
|
||||
|
||||
// Delete QSOs
|
||||
// do not delete active logbook
|
||||
if ($this->session->userdata('active_station_logbook') === $clean_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete logbook
|
||||
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||
$this->db->where('logbook_id', $id);
|
||||
$this->db->delete('station_logbooks');
|
||||
|
@ -50,9 +50,16 @@ class Stations extends CI_Model {
|
||||
* Adds post material into the station profile table.
|
||||
*/
|
||||
function add() {
|
||||
// check if user has no active station profile yet
|
||||
$station_active = null;
|
||||
if ($this->find_active() === '0') {
|
||||
$station_active = 1;
|
||||
}
|
||||
|
||||
// Create data array with field values
|
||||
$data = array(
|
||||
'user_id' => $this->session->userdata('user_id'),
|
||||
'station_active' => $station_active,
|
||||
'station_profile_name' => xss_clean($this->input->post('station_profile_name', true)),
|
||||
'station_gridsquare' => xss_clean(strtoupper($this->input->post('gridsquare', true))),
|
||||
'station_city' => xss_clean($this->input->post('city', true)),
|
||||
@ -106,6 +113,11 @@ class Stations extends CI_Model {
|
||||
// Clean ID
|
||||
$clean_id = $this->security->xss_clean($id);
|
||||
|
||||
// do not delete active station
|
||||
if ($clean_id === $this->find_active()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete QSOs
|
||||
$this->db->where('station_id', $id);
|
||||
$this->db->delete($this->config->item('table_name'));
|
||||
|
@ -43,8 +43,10 @@
|
||||
|
||||
<a href="<?php echo site_url('logbooks/edit')."/".$row->logbook_id; ?>" class="btn btn-outline-primary btn-sm"><i class="fas fa-edit"></i> Edit</a>
|
||||
|
||||
<a href="<?php echo site_url('Logbooks/delete')."/".$row->logbook_id; ?>" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want delete station profile <?php echo $row->logbook_name; ?> this will delete all QSOs within this station logbook?');"><i class="fas fa-trash-alt"></i> Delete</a>
|
||||
</td>
|
||||
<?php if($this->session->userdata('active_station_logbook') != $row->logbook_id) { ?>
|
||||
<a href="<?php echo site_url('Logbooks/delete')."/".$row->logbook_id; ?>" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want delete station profile <?php echo $row->logbook_name; ?> this will delete all QSOs within this station logbook?');"><i class="fas fa-trash-alt"></i> Delete</a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
|
@ -61,7 +61,7 @@
|
||||
<td><?php echo $row->station_country;?></td>
|
||||
<td><?php echo $row->station_gridsquare;?></td>
|
||||
<td style="text-align: center">
|
||||
<?php if($row->station_active != 1) { ?>
|
||||
<?php if($row->station_active != 1) { ?>
|
||||
<a href="<?php echo site_url('station/set_active/').$current_active."/".$row->station_id; ?>" class="btn btn-outline-secondary btn-sm" onclick="return confirm('Are you sure you want to make station <?php echo $row->station_profile_name; ?> the active station?');">Set Active</a>
|
||||
<?php } else { ?>
|
||||
<span class="badge badge-success">Active Station</span>
|
||||
@ -84,7 +84,10 @@
|
||||
<a href="<?php echo site_url('station/deletelog')."/".$row->station_id; ?>" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want to delete all QSOs within this station profile?');"><i class="fas fa-trash-alt"></i> Empty Log</a></td>
|
||||
</td>
|
||||
<td>
|
||||
<a href="<?php echo site_url('station/delete')."/".$row->station_id; ?>" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want delete station profile <?php echo $row->station_profile_name; ?> this will delete all QSOs within this station profile?');"><i class="fas fa-trash-alt"></i> Delete Profile</a></td>
|
||||
<?php if($row->station_active != 1) { ?>
|
||||
<a href="<?php echo site_url('station/delete')."/".$row->station_id; ?>" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want delete station profile <?php echo $row->station_profile_name; ?> this will delete all QSOs within this station profile?');"><i class="fas fa-trash-alt"></i> Delete Profile</a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
|
Loading…
Reference in New Issue
Block a user