[Station Logbooks] Added functions to handle editing
这个提交包含在:
父节点
ee0a93b48a
当前提交
79d9167e8b
共有 3 个文件被更改,包括 97 次插入 和 0 次删除
|
|
@ -49,6 +49,38 @@ class Logbooks extends CI_Controller {
|
|||
}
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->load->model('logbooks_model');
|
||||
|
||||
$station_logbook_id = $this->security->xss_clean($id);
|
||||
|
||||
$station_logbook_details_query = $this->logbooks_model->logbook($station_logbook_id);
|
||||
|
||||
$data['station_logbook_details'] = $station_logbook_details_query->row();
|
||||
|
||||
$data['page_title'] = "Edit Station Logbook";
|
||||
|
||||
$this->form_validation->set_rules('station_logbook_name', 'Station Logbook Name', 'required');
|
||||
|
||||
if ($this->form_validation->run() == FALSE)
|
||||
{
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('logbooks/edit');
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->logbooks_model->edit();
|
||||
|
||||
$data['notice'] = "Station Logbooks ".$this->security->xss_clean($this->input->post('station_logbook_name', true))." Updated";
|
||||
|
||||
redirect('logbooks');
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id) {
|
||||
$this->load->model('logbooks_model');
|
||||
$this->logbooks_model->delete($id);
|
||||
|
|
|
|||
|
|
@ -34,5 +34,24 @@ class Logbooks_model extends CI_Model {
|
|||
$this->db->where('logbook_id', $id);
|
||||
$this->db->delete('station_logbooks');
|
||||
}
|
||||
|
||||
function edit() {
|
||||
$data = array(
|
||||
'logbook_name' => xss_clean($this->input->post('station_logbook_name', true)),
|
||||
);
|
||||
|
||||
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||
$this->db->where('logbook_id', xss_clean($this->input->post('logbook_id', true)));
|
||||
$this->db->update('station_logbooks', $data);
|
||||
}
|
||||
|
||||
function logbook($id) {
|
||||
// Clean ID
|
||||
$clean_id = $this->security->xss_clean($id);
|
||||
|
||||
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||
$this->db->where('logbook_id', $clean_id);
|
||||
return $this->db->get('station_logbooks');
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<div class="container" id="create_station_profile">
|
||||
|
||||
<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 method="post" action="<?php echo site_url('logbooks/edit/'); ?><?php echo $station_logbook_details->logbook_id; ?>" name="create_profile">
|
||||
|
||||
<input type="hidden" name="logbook_id" value="<?php echo $station_logbook_details->logbook_id; ?>">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md">
|
||||
<div class="card">
|
||||
<div class="card-header"><?php echo $page_title; ?>: <?php echo $station_logbook_details->logbook_name; ?></div>
|
||||
<div class="card-body">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="stationLogbookNameInput">Station Logbook Name</label>
|
||||
<input type="text" class="form-control" name="station_logbook_name" id="stationLogbookNameInput" aria-describedby="stationLogbookNameInputHelp" value="<?php if(set_value('station_logbook_name') != "") { echo set_value('station_logbook_name'); } else { echo $station_logbook_details->logbook_name; } ?>" required>
|
||||
<small id="stationLogbookNameInputHelp" class="form-text text-muted">Shortname for the station location. For example: Home (IO87IP)</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<button type="submit" class="btn btn-primary"><i class="fas fa-plus-square"></i> Update Station Logbook</button>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
正在加载…
在新工单中引用