From f47717bbc18d4c60cd4fa15843c7081694af1feb Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Sat, 3 Jun 2023 08:46:52 +0200 Subject: [PATCH] [QSL Labels] Added label editing --- application/controllers/Labels.php | 18 +++- application/models/Labels_model.php | 35 +++++++- application/views/labels/create.php | 4 +- application/views/labels/edit.php | 122 ++++++++++++++++++++++++++++ 4 files changed, 173 insertions(+), 6 deletions(-) create mode 100644 application/views/labels/edit.php diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index da89aadd..5241d203 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -145,8 +145,24 @@ class Labels extends CI_Controller { $pdf->Output(); } - public function edit() { + public function edit($id) { + $this->load->model('labels_model'); + $cleanid = $this->security->xss_clean($id); + + $data['label'] = $this->labels_model->getLabel($cleanid); + + $data['page_title'] = "Edit Label"; + + $this->load->view('interface_assets/header', $data); + $this->load->view('labels/edit'); + $this->load->view('interface_assets/footer'); + } + + public function updateLabel($id) { + $this->load->model('labels_model'); + $this->labels_model->updateLabel($id); + redirect('labels'); } public function delete($id) { diff --git a/application/models/Labels_model.php b/application/models/Labels_model.php index a7139d24..78246ba7 100644 --- a/application/models/Labels_model.php +++ b/application/models/Labels_model.php @@ -18,15 +18,44 @@ class Labels_model extends CI_Model { 'font_size' => xss_clean($this->input->post('font_size', true)), 'qsos' => xss_clean($this->input->post('label_qsos', true)), 'last_modified' => date('Y-m-d H:i:s'), - ); $this->db->insert('label_types', $data); } - function updateLabel() { - + function getLabel($id) { + $this->db->where('user_id', $this->session->userdata('user_id')); + $this->db->where('id', $id); + $query = $this->db->get('label_types'); + + return $query->row(); + } + + function updateLabel($id) { + $data = array( + 'user_id' => $this->session->userdata('user_id'), + 'label_name' => xss_clean($this->input->post('label_name', true)), + 'paper_type' => xss_clean($this->input->post('paper_type', true)), + 'metric' => xss_clean($this->input->post('measurementType', true)), + 'marginleft' => xss_clean($this->input->post('marginLeft', true)), + 'margintop' => xss_clean($this->input->post('marginTop', true)), + 'nx' => xss_clean($this->input->post('NX', true)), + 'ny' => xss_clean($this->input->post('NY', true)), + 'spacex' => xss_clean($this->input->post('SpaceX', true)), + 'spacey' => xss_clean($this->input->post('SpaceY', true)), + 'width' => xss_clean($this->input->post('width', true)), + 'height' => xss_clean($this->input->post('height', true)), + 'font_size' => xss_clean($this->input->post('font_size', true)), + 'qsos' => xss_clean($this->input->post('label_qsos', 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('label_types', $data); } function deleteLabel($id) { diff --git a/application/views/labels/create.php b/application/views/labels/create.php index 7626961d..0fe235d4 100644 --- a/application/views/labels/create.php +++ b/application/views/labels/create.php @@ -21,7 +21,7 @@
- Label name used for display purposes so pick something meaningful perhaps the label style. + Label name used for display purposes, so pick something meaningful, perhaps the label style.
@@ -36,7 +36,7 @@
diff --git a/application/views/labels/edit.php b/application/views/labels/edit.php new file mode 100644 index 00000000..6abc826a --- /dev/null +++ b/application/views/labels/edit.php @@ -0,0 +1,122 @@ +
+ +
+ session->flashdata('message')) { ?> + +
+

session->flashdata('message'); ?>

+
+ + + + +
+ +
+

+ +
+ + +
+ + + Label name used for display purposes so pick something meaningful perhaps the label style. +
+ +
+ +
+ +
+ + +
+ +
+
+ +
+ +
+ + Top margin of labels +
+ + +
+ + Left margin of labels. +
+
+ +
+ +
+ + 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. +
+ + +
+ +
+
+ + + +
+
+ +
+ +
+
\ No newline at end of file