diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index 366c4760..d3c7ae77 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -43,6 +43,8 @@ class Labels extends CI_Controller { $data['labels'] = $this->labels_model->fetchLabels($this->session->userdata('user_id')); + $data['papertypes'] = $this->labels_model->fetchPapertypes($this->session->userdata('user_id')); + $data['qsos'] = $this->labels_model->fetchQsos($this->session->userdata('user_id')); $footerData = []; @@ -351,4 +353,32 @@ class Labels extends CI_Controller { $data['stationid'] = xss_clean($this->input->post('stationid')); $this->load->view('labels/startatform', $data); } + + public function editPaper($id) { + $this->load->model('labels_model'); + + $cleanid = $this->security->xss_clean($id); + + $data['paper'] = $this->labels_model->getPaper($cleanid); + + $data['page_title'] = "Edit Paper"; + + $this->load->view('interface_assets/header', $data); + $this->load->view('labels/editpaper'); + $this->load->view('interface_assets/footer'); + } + + public function updatePaper($id) { + $this->load->model('labels_model'); + $this->labels_model->updatePaper($id); + $this->session->set_flashdata('message', 'Paper was saved.'); + redirect('labels'); + } + + public function deletePaper($id) { + $this->load->model('labels_model'); + $this->labels_model->deletePaper($id); + $this->session->set_flashdata('warning', 'Paper was deleted.'); + redirect('labels'); + } } diff --git a/application/models/Labels_model.php b/application/models/Labels_model.php index 9f528f47..4e57cd0c 100644 --- a/application/models/Labels_model.php +++ b/application/models/Labels_model.php @@ -87,6 +87,13 @@ class Labels_model extends CI_Model { return $query->result(); } + function fetchPapertypes($user_id) { + $this->db->where('user_id', $user_id); + $query = $this->db->get('paper_types'); + + return $query->result(); + } + function fetchQsos($user_id) { $qsl = "select count(*) count, station_profile.station_profile_name, station_profile.station_callsign, station_profile.station_id, station_profile.station_gridsquare @@ -159,4 +166,35 @@ class Labels_model extends CI_Model { return $query; } + + function updatePaper($id) { + $data = array( + 'user_id' => $this->session->userdata('user_id'), + 'paper_name' => xss_clean($this->input->post('paper_name', true)), + 'metric' => xss_clean($this->input->post('measurementType', true)), + 'width' => xss_clean($this->input->post('width', true)), + 'height' => xss_clean($this->input->post('height', true)), + 'last_modified' => date('Y-m-d H:i:s'), + ); + + $cleanid = $this->security->xss_clean($id); + + $this->db->where('user_id', $this->session->userdata('user_id')); + $this->db->where('id', $cleanid); + $this->db->update('paper_types', $data); + } + + function deletePaper($id) { + $cleanid = xss_clean($id); + + $this->db->delete('paper_types', array('id' => $cleanid, 'user_id' => $this->session->userdata('user_id'))); + } + + function getPaper($id) { + $this->db->where('user_id', $this->session->userdata('user_id')); + $this->db->where('id', $id); + $query = $this->db->get('paper_types'); + + return $query->row(); + } } diff --git a/application/views/labels/editpaper.php b/application/views/labels/editpaper.php index 695fded7..716d08ad 100644 --- a/application/views/labels/editpaper.php +++ b/application/views/labels/editpaper.php @@ -10,7 +10,7 @@ -
+

@@ -18,99 +18,36 @@
-
- - - Label name used for display purposes so pick something meaningful perhaps the label style. -
- -
- -
- -
- - -
+
+ +
+ + Paper name used for display purposes, so pick something meaningful. +
+ +
- +
- - Top margin of labels + + Total width of paper.
- +
- - Left margin of labels. + + Total width of paper.
-
- -
- - Number of labels horizontally across the page. -
- - -
- - Number of labels vertically across the page. -
-
- -
- -
- - Horizontal space between 2 labels. -
- - -
- - Vertical space between 2 labels. -
-
- -
- -
- - Total width of one label. -
- - -
- - Total height of one label -
-
- -
- -
- - Font size used on the label don't go too big. -
- - -
- -
-
- +
diff --git a/application/views/labels/index.php b/application/views/labels/index.php index db63184a..73375454 100644 --- a/application/views/labels/index.php +++ b/application/views/labels/index.php @@ -28,10 +28,41 @@
Create New Label Type Create New Paper Type +

+ +

Paper types

+ + + + + + + + + + + + + + + + + + + + + + + +
NameMeasurementWidthHeightLast ModifiedEditDelete
paper_name; ?>metric; ?>width; ?>height; ?>last_modified; ?>
'; + } ?> -
';?> + +
+

Label types