From 8ac7a8e3d601550bf71b7c13d220e9747e7ec75b Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Tue, 1 Aug 2023 18:55:42 +0200 Subject: [PATCH 01/29] [Labels] Adding custom paper types --- application/config/migration.php | 2 +- .../133_create_label_paper_types_table.php | 63 +++++++++ application/models/Labels_model.php | 26 +++- application/views/labels/createpaper.php | 57 +++++++++ application/views/labels/editpaper.php | 120 ++++++++++++++++++ application/views/labels/index.php | 3 +- 6 files changed, 263 insertions(+), 8 deletions(-) create mode 100644 application/migrations/133_create_label_paper_types_table.php create mode 100644 application/views/labels/createpaper.php create mode 100644 application/views/labels/editpaper.php diff --git a/application/config/migration.php b/application/config/migration.php index 688dfffe..6a1ed952 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE; | */ -$config['migration_version'] = 132; +$config['migration_version'] = 133; /* |-------------------------------------------------------------------------- diff --git a/application/migrations/133_create_label_paper_types_table.php b/application/migrations/133_create_label_paper_types_table.php new file mode 100644 index 00000000..34e87528 --- /dev/null +++ b/application/migrations/133_create_label_paper_types_table.php @@ -0,0 +1,63 @@ +db->table_exists('paper_types')) { + $this->dbforge->add_field(array( + 'id' => array( + 'type' => 'INT', + 'constraint' => 5, + 'unsigned' => TRUE, + 'auto_increment' => TRUE + ), + + 'user_id' => array( + 'type' => 'INT', + 'constraint' => 5, + ), + + 'paper_name' => array( + 'type' => 'VARCHAR', + 'constraint' => '250', + ), + + 'metric' => array( + 'type' => 'VARCHAR', + 'constraint' => '10', + ), + + 'width' => array( + 'type' => 'DECIMAL', + 'constraint' => '6,3', + 'null' => TRUE, + ), + + 'height' => array( + 'type' => 'DECIMAL', + 'constraint' => '6,3', + 'null' => TRUE, + ), + + 'last_modified' => array( + 'type' => 'timestamp', + 'null' => TRUE, + ), + )); + + $this->dbforge->add_key('id', TRUE); + $this->dbforge->add_key('user_id', TRUE); + + $this->dbforge->create_table('paper_types'); + } + + } + + public function down(){ + if ($this->db->table_exists('paper_types')) { + $this->dbforge->drop_table('paper_types'); + } + } +} diff --git a/application/models/Labels_model.php b/application/models/Labels_model.php index 41db763a..9f528f47 100644 --- a/application/models/Labels_model.php +++ b/application/models/Labels_model.php @@ -25,11 +25,25 @@ class Labels_model extends CI_Model { } + function addPaper() { + $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'), + ); + + $this->db->insert('paper_types', $data); + + } + 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(); } @@ -63,26 +77,26 @@ class Labels_model extends CI_Model { function deleteLabel($id) { $cleanid = xss_clean($id); - $this->db->delete('label_types', array('id' => $cleanid, 'user_id' => $this->session->userdata('user_id'))); + $this->db->delete('label_types', array('id' => $cleanid, 'user_id' => $this->session->userdata('user_id'))); } function fetchLabels($user_id) { $this->db->where('user_id', $user_id); $query = $this->db->get('label_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 - from ". $this->config->item('table_name') . " as l + from ". $this->config->item('table_name') . " as l join station_profile on l.station_id = station_profile.station_id where l.COL_QSL_SENT in ('R', 'Q') and station_profile.user_id = " . $user_id . " group by station_profile.station_profile_name, station_profile.station_callsign, station_profile.station_id, station_profile.station_gridsquare order by station_profile.station_callsign"; - + $query = $this->db->query($qsl); return $query->result(); @@ -92,7 +106,7 @@ class Labels_model extends CI_Model { $this->db->where('user_id', $this->session->userdata('user_id')); $this->db->where('useforprint', '1'); $query = $this->db->get('label_types'); - + return $query->row(); } diff --git a/application/views/labels/createpaper.php b/application/views/labels/createpaper.php new file mode 100644 index 00000000..d9eaf683 --- /dev/null +++ b/application/views/labels/createpaper.php @@ -0,0 +1,57 @@ +
+ +
+ session->flashdata('message')) { ?> + +
+

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

+
+ + + + +
+ +
+

+ +
+ + +
+ +
+ + Paper name used for display purposes, so pick something meaningful. +
+ +
+ +
+
+ +
+ +
+ + Total width of paper. +
+ + +
+ + Total height of paper +
+
+ + +
+
+ +
+ +
+
diff --git a/application/views/labels/editpaper.php b/application/views/labels/editpaper.php new file mode 100644 index 00000000..695fded7 --- /dev/null +++ b/application/views/labels/editpaper.php @@ -0,0 +1,120 @@ +
+ +
+ 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. +
+ + +
+ +
+
+ +
+
+ +
+ +
+
diff --git a/application/views/labels/index.php b/application/views/labels/index.php index 6e655133..db63184a 100644 --- a/application/views/labels/index.php +++ b/application/views/labels/index.php @@ -26,7 +26,8 @@

QSL Card Labels

- Create New Label Type + Create New Label Type + Create New Paper Type Date: Tue, 1 Aug 2023 18:59:05 +0200 Subject: [PATCH 02/29] Added updated controller --- application/controllers/Labels.php | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index ef12376b..366c4760 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -88,6 +88,39 @@ class Labels extends CI_Controller { } + /* + |-------------------------------------------------------------------------- + | Function: createpaper + |-------------------------------------------------------------------------- + | + | Shows the form used to create a paper type. + | + */ + public function createpaper() { + + $data['page_title'] = "Create Paper Type"; + + $this->load->library('form_validation'); + + $this->form_validation->set_rules('paper_name', 'Paper Name', 'required'); + + if ($this->form_validation->run() == FALSE) + { + $this->load->view('interface_assets/header', $data); + $this->load->view('labels/createpaper'); + $this->load->view('interface_assets/footer'); + } + else + { + $this->load->model('labels_model'); + $this->labels_model->addPaper(); + + redirect('labels'); + } + + } + + public function printids() { $ids = xss_clean(json_decode($this->input->post('id'))); $offset = xss_clean($this->input->post('startat')); From 206c10f80a4df9ab95adcaf2dc3fea044b2c5782 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 2 Aug 2023 10:05:24 +0200 Subject: [PATCH 03/29] [Labels] Added edit/delete paper type --- application/controllers/Labels.php | 30 ++++++++ application/models/Labels_model.php | 38 ++++++++++ application/views/labels/editpaper.php | 99 +++++--------------------- application/views/labels/index.php | 35 ++++++++- 4 files changed, 119 insertions(+), 83 deletions(-) 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

From a043060a8c4dbbc21fa8d947c5f3c4fe424c3e98 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 2 Aug 2023 10:17:22 +0200 Subject: [PATCH 04/29] [Labels] Added papertypes to dropdown for editing labels --- application/controllers/Labels.php | 2 ++ application/views/labels/edit.php | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index d3c7ae77..cc7dd50f 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -322,6 +322,8 @@ class Labels extends CI_Controller { $data['label'] = $this->labels_model->getLabel($cleanid); + $data['papertypes'] = $this->labels_model->fetchPapertypes($this->session->userdata('user_id')); + $data['page_title'] = "Edit Label"; $this->load->view('interface_assets/header', $data); diff --git a/application/views/labels/edit.php b/application/views/labels/edit.php index 695fded7..f9352562 100644 --- a/application/views/labels/edit.php +++ b/application/views/labels/edit.php @@ -28,8 +28,16 @@
From a988f608977140a3c5a42c720be73a5308fe149b Mon Sep 17 00:00:00 2001 From: int2001 Date: Wed, 2 Aug 2023 08:32:00 +0000 Subject: [PATCH 05/29] Added orientiation (default "P") to Label --- src/Label/PDF_Label.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Label/PDF_Label.php b/src/Label/PDF_Label.php index eb93bec6..fcf72ecb 100644 --- a/src/Label/PDF_Label.php +++ b/src/Label/PDF_Label.php @@ -132,7 +132,7 @@ class PDF_Label extends tfpdf { } // Print a label - function Add_Label($text) { + function Add_Label($text,$orientation = 'L') { $this->_COUNTX++; if ($this->_COUNTX == $this->_X_Number) { // Row full, we start a new one @@ -141,7 +141,7 @@ class PDF_Label extends tfpdf { if ($this->_COUNTY == $this->_Y_Number) { // End of page reached, we start a new one $this->_COUNTY=0; - $this->AddPage(); + $this->AddPage($orientation); } } From 41cd48f13db239ba95d0b6a43f9e3c9047921380 Mon Sep 17 00:00:00 2001 From: int2001 Date: Wed, 2 Aug 2023 08:33:03 +0000 Subject: [PATCH 06/29] Default at first everywhere(!) P --- src/Label/PDF_Label.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Label/PDF_Label.php b/src/Label/PDF_Label.php index fcf72ecb..3d44ac7c 100644 --- a/src/Label/PDF_Label.php +++ b/src/Label/PDF_Label.php @@ -132,7 +132,7 @@ class PDF_Label extends tfpdf { } // Print a label - function Add_Label($text,$orientation = 'L') { + function Add_Label($text,$orientation = 'P') { $this->_COUNTX++; if ($this->_COUNTX == $this->_X_Number) { // Row full, we start a new one From d76e7e74d5748ac7030284a4a9b2fabf215b0859 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 2 Aug 2023 10:34:19 +0200 Subject: [PATCH 07/29] [Labels] Added custom papertypes to create label --- application/controllers/Labels.php | 3 +++ application/views/labels/create.php | 8 ++++++++ application/views/labels/edit.php | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index cc7dd50f..e3bb0cbe 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -71,6 +71,9 @@ class Labels extends CI_Controller { $data['page_title'] = "Create Label Type"; $this->load->library('form_validation'); + $this->load->model('labels_model'); + + $data['papertypes'] = $this->labels_model->fetchPapertypes($this->session->userdata('user_id')); $this->form_validation->set_rules('label_name', 'Label Name', 'required'); diff --git a/application/views/labels/create.php b/application/views/labels/create.php index daf88f55..39b3c3b7 100644 --- a/application/views/labels/create.php +++ b/application/views/labels/create.php @@ -28,8 +28,16 @@
diff --git a/application/views/labels/edit.php b/application/views/labels/edit.php index f9352562..ff2d1b84 100644 --- a/application/views/labels/edit.php +++ b/application/views/labels/edit.php @@ -35,7 +35,9 @@ paper_name . '>' . ucwords(strtolower(($paper->paper_name))) . ''; + echo ''; } ?> From ed6ca09b676eb045324a8c2bdd7e3e02e5f078f9 Mon Sep 17 00:00:00 2001 From: int2001 Date: Wed, 2 Aug 2023 09:34:32 +0000 Subject: [PATCH 08/29] Enhances PDFLabel (and some parts of label-controller/model) to custom-papertypes. UNTESTED --- application/controllers/Labels.php | 8 +++++-- application/models/Labels_model.php | 8 +++++++ src/Label/PDF_Label.php | 37 +++++++++++++++-------------- src/Label/tfpdf.php | 5 +++- 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index e3bb0cbe..2c1a5fae 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -157,8 +157,10 @@ class Labels extends CI_Controller { try { if ($label) { + $ptype=$this->labels_model->getPaperType($label->paper_type); // fetch papersize out of paper-table + var_dump($ptype); $pdf = new PDF_Label(array( - 'paper-size' => $label->paper_type, + 'paper-size' => 'custom', // $label->paper_type, // The only Type left is "custom" because A4 and so on are also defined at paper_types 'metric' => $label->metric, 'marginLeft' => $label->marginleft, 'marginTop' => $label->margintop, @@ -168,7 +170,9 @@ class Labels extends CI_Controller { 'SpaceY' => $label->spacey, 'width' => $label->width, 'height' => $label->height, - 'font-size' => $label->font_size + 'font-size' => $label->font_size, + 'pgX' => $ptype->width, + 'pgY' => $ptype->height )); } else { if ($jscall) { diff --git a/application/models/Labels_model.php b/application/models/Labels_model.php index 4e57cd0c..18835692 100644 --- a/application/models/Labels_model.php +++ b/application/models/Labels_model.php @@ -117,6 +117,14 @@ class Labels_model extends CI_Model { return $query->row(); } + function getPaperType($ptype) { + $this->db->where('user_id', $this->session->userdata('user_id')); + $this->db->where('id',$ptype); + $query = $this->db->get('paper_types'); + + return $query->row(); + } + function saveDefaultLabel($id) { $sql = 'update label_types set useforprint = 0 where user_id = ' . $this->session->userdata('user_id'); $this->db->query($sql); diff --git a/src/Label/PDF_Label.php b/src/Label/PDF_Label.php index 3d44ac7c..e4083056 100644 --- a/src/Label/PDF_Label.php +++ b/src/Label/PDF_Label.php @@ -69,25 +69,26 @@ class PDF_Label extends tfpdf { ); // Constructor - function __construct($format, $unit='mm', $posX=1, $posY=1) { - if (is_array($format)) { - // Custom format - $Tformat = $format; - } else { - // Built-in format - if (!isset($this->_Avery_Labels[$format])) - $this->Error('Unknown label format: '.$format); - $Tformat = $this->_Avery_Labels[$format]; - } + function __construct($format, $unit='mm', $posX=1, $posY=1, $pgX=0,$pgY=0) { + if (is_array($format)) { + // Custom format + var_dump("X".$pgX); + $Tformat = $format; + } else { + // Built-in format + if (!isset($this->_Avery_Labels[$format])) + $this->Error('Unknown label format: '.$format); + $Tformat = $this->_Avery_Labels[$format]; + } - parent::__construct('P', $unit, $Tformat['paper-size']); - $this->_Metric_Doc = $unit; - $this->_Set_Format($Tformat); - $this->SetFont('Arial'); - $this->SetMargins(0,0); - $this->SetAutoPageBreak(false); - $this->_COUNTX = $posX-2; - $this->_COUNTY = $posY-1; + parent::__construct('P', $unit, $Tformat['paper-size'],$Tformat['pgX'],$Tformat['pgY']); + $this->_Metric_Doc = $unit; + $this->_Set_Format($Tformat); + $this->SetFont('Arial'); + $this->SetMargins(0,0); + $this->SetAutoPageBreak(false); + $this->_COUNTX = $posX-2; + $this->_COUNTY = $posY-1; } function _Set_Format($format) { diff --git a/src/Label/tfpdf.php b/src/Label/tfpdf.php index a6d6825d..038066b8 100644 --- a/src/Label/tfpdf.php +++ b/src/Label/tfpdf.php @@ -74,7 +74,7 @@ protected $PDFVersion; // PDF version number * Public methods * *******************************************************************************/ -function __construct($orientation='P', $unit='mm', $size='A4') +function __construct($orientation='P', $unit='mm', $size='A4',$pgX = 0,$pgY =0) { // Some checks $this->_dochecks(); @@ -131,6 +131,9 @@ function __construct($orientation='P', $unit='mm', $size='A4') // Page sizes $this->StdPageSizes = array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28), 'letter'=>array(612,792), 'legal'=>array(612,1008)); + if ($size == 'custom') { + $size=array($pgX,$pgY); + } $size = $this->_getpagesize($size); $this->DefPageSize = $size; $this->CurPageSize = $size; From 4a19e0096558f78e16de7a82291353c492cd2630 Mon Sep 17 00:00:00 2001 From: int2001 Date: Wed, 2 Aug 2023 09:46:19 +0000 Subject: [PATCH 09/29] Moved from paper_id to paper_name --- application/controllers/Labels.php | 2 +- application/models/Labels_model.php | 2 +- src/Label/PDF_Label.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index 2c1a5fae..09faf392 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -158,7 +158,7 @@ class Labels extends CI_Controller { try { if ($label) { $ptype=$this->labels_model->getPaperType($label->paper_type); // fetch papersize out of paper-table - var_dump($ptype); + // var_dump($ptype); $pdf = new PDF_Label(array( 'paper-size' => 'custom', // $label->paper_type, // The only Type left is "custom" because A4 and so on are also defined at paper_types 'metric' => $label->metric, diff --git a/application/models/Labels_model.php b/application/models/Labels_model.php index 18835692..27b8c188 100644 --- a/application/models/Labels_model.php +++ b/application/models/Labels_model.php @@ -119,7 +119,7 @@ class Labels_model extends CI_Model { function getPaperType($ptype) { $this->db->where('user_id', $this->session->userdata('user_id')); - $this->db->where('id',$ptype); + $this->db->where('paper_name',$ptype); $query = $this->db->get('paper_types'); return $query->row(); diff --git a/src/Label/PDF_Label.php b/src/Label/PDF_Label.php index e4083056..a65be9b6 100644 --- a/src/Label/PDF_Label.php +++ b/src/Label/PDF_Label.php @@ -72,7 +72,7 @@ class PDF_Label extends tfpdf { function __construct($format, $unit='mm', $posX=1, $posY=1, $pgX=0,$pgY=0) { if (is_array($format)) { // Custom format - var_dump("X".$pgX); + // var_dump("X".$pgX); $Tformat = $format; } else { // Built-in format From 04c7db19203ee91f8ffaf8d74a4af40b553aec77 Mon Sep 17 00:00:00 2001 From: int2001 Date: Wed, 2 Aug 2023 10:07:22 +0000 Subject: [PATCH 10/29] Fixed Units to mm --- application/views/labels/createpaper.php | 4 ++-- application/views/labels/editpaper.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/application/views/labels/createpaper.php b/application/views/labels/createpaper.php index d9eaf683..91d47a0b 100644 --- a/application/views/labels/createpaper.php +++ b/application/views/labels/createpaper.php @@ -27,8 +27,8 @@
diff --git a/application/views/labels/editpaper.php b/application/views/labels/editpaper.php index 716d08ad..8bb02108 100644 --- a/application/views/labels/editpaper.php +++ b/application/views/labels/editpaper.php @@ -28,7 +28,7 @@
From f2272e9fb520702421773c77af11843bd6988d40 Mon Sep 17 00:00:00 2001 From: int2001 Date: Wed, 2 Aug 2023 10:20:38 +0000 Subject: [PATCH 11/29] 1st version with orientation --- application/controllers/Labels.php | 24 +++++++++---------- .../133_create_label_paper_types_table.php | 6 +++++ application/views/labels/create.php | 5 ---- application/views/labels/edit.php | 5 ---- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index 09faf392..97ca48b5 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -196,7 +196,7 @@ class Labels extends CI_Controller { } define('FPDF_FONTPATH', './src/Label/font/'); - $pdf->AddPage(); + $pdf->AddPage($ptype->orientation); if ($label->font == 'DejaVuSans') { // leave this here, for future Use $pdf->AddFont($label->font,'','DejaVuSansMono.ttf',true); @@ -208,9 +208,9 @@ class Labels extends CI_Controller { if ($qsos->num_rows() > 0) { if ($label->qsos == 1) { - $this->makeMultiQsoLabel($qsos->result(), $pdf, 1, $offset); + $this->makeMultiQsoLabel($qsos->result(), $pdf, 1, $offset, $ptype->orientation); } else { - $this->makeMultiQsoLabel($qsos->result(), $pdf, $label->qsos, $offset); + $this->makeMultiQsoLabel($qsos->result(), $pdf, $label->qsos, $offset, $ptype->orientation); } } else { $this->session->set_flashdata('message', '0 QSOs found for print!'); @@ -219,7 +219,7 @@ class Labels extends CI_Controller { $pdf->Output(); } - function makeMultiQsoLabel($qsos, $pdf, $numberofqsos, $offset) { + function makeMultiQsoLabel($qsos, $pdf, $numberofqsos, $offset, $orientation) { $text = ''; $current_callsign = ''; $current_sat = ''; @@ -228,7 +228,7 @@ class Labels extends CI_Controller { $qso_data = []; if ($offset !== 1) { for ($i = 1; $i < $offset; $i++) { - $pdf->Add_Label(''); + $pdf->Add_Label('',$orientation); } } foreach($qsos as $qso) { @@ -236,7 +236,7 @@ class Labels extends CI_Controller { ( ($qso->COL_BAND_RX !== $current_sat_bandrx) && ($this->pretty_sat_mode($qso->COL_SAT_MODE) !== '')) ) { // ((($qso->COL_SAT_NAME ?? '' !== $current_sat) || ($qso->COL_CALL !== $current_callsign)) && ($qso->COL_SAT_NAME ?? '' !== '') && ($col->COL_BAND_RX ?? '' !== $current_sat_bandrx))) { if (!empty($qso_data)) { - $this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos); + $this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos, $orientation); $qso_data = []; } $current_callsign = $qso->COL_CALL; @@ -258,7 +258,7 @@ class Labels extends CI_Controller { ]; } if (!empty($qso_data)) { - $this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos); + $this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos, $orientation); } } // New begin @@ -266,7 +266,7 @@ class Labels extends CI_Controller { return(strlen($sat_mode ?? '') == 2 ? (strtoupper($sat_mode[0]).'/'.strtoupper($sat_mode[1])) : strtoupper($sat_mode ?? '')); } - function finalizeData($pdf, $current_callsign, &$preliminaryData, $qso_per_label) { + function finalizeData($pdf, $current_callsign, &$preliminaryData, $qso_per_label,$orientation) { $tableData = []; $count_qso = 0; @@ -286,7 +286,7 @@ class Labels extends CI_Controller { if($count_qso == $qso_per_label){ - $this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso); + $this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso,$orientation); $tableData = []; // reset the data $count_qso = 0; // reset the counter } @@ -294,12 +294,12 @@ class Labels extends CI_Controller { } // generate label for remaining QSOs if($count_qso > 0){ - $this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso); + $this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso,$orientation); $preliminaryData = []; // reset the data } } - function generateLabel($pdf, $current_callsign, $tableData,$numofqsos,$qso){ + function generateLabel($pdf, $current_callsign, $tableData,$numofqsos,$qso,$orientation){ $builder = new \AsciiTable\Builder(); $builder->addRows($tableData); $text = "Confirming QSO".($numofqsos>1 ? 's' : '')." with "; @@ -317,7 +317,7 @@ class Labels extends CI_Controller { } $text .= "\nThanks for the QSO".($numofqsos>1 ? 's' : ''); $text .= " | ".($qso['qsl_recvd'] == 'Y' ? 'TNX' : 'PSE')." QSL"; - $pdf->Add_Label($text); + $pdf->Add_Label($text,$orientation); } // New End diff --git a/application/migrations/133_create_label_paper_types_table.php b/application/migrations/133_create_label_paper_types_table.php index 34e87528..2146b98c 100644 --- a/application/migrations/133_create_label_paper_types_table.php +++ b/application/migrations/133_create_label_paper_types_table.php @@ -35,6 +35,12 @@ class Migration_create_label_paper_types_table extends CI_Migration { 'null' => TRUE, ), + 'orientation' => array( + 'type' => 'VARCHAR', + 'constraint' => '1', + 'null' => TRUE, + ), + 'height' => array( 'type' => 'DECIMAL', 'constraint' => '6,3', diff --git a/application/views/labels/create.php b/application/views/labels/create.php index 39b3c3b7..9a074008 100644 --- a/application/views/labels/create.php +++ b/application/views/labels/create.php @@ -28,11 +28,6 @@
- - - - - paper_name . '"'; From d5b8204e57ae88b80a0c4823a0b52ebaff255988 Mon Sep 17 00:00:00 2001 From: int2001 Date: Wed, 2 Aug 2023 10:35:12 +0000 Subject: [PATCH 12/29] Added Orientation to views/controllers/model for paper --- application/models/Labels_model.php | 2 ++ application/views/labels/createpaper.php | 13 +++++++++++++ application/views/labels/editpaper.php | 11 +++++++++++ 3 files changed, 26 insertions(+) diff --git a/application/models/Labels_model.php b/application/models/Labels_model.php index 27b8c188..ac2c3e61 100644 --- a/application/models/Labels_model.php +++ b/application/models/Labels_model.php @@ -32,6 +32,7 @@ class Labels_model extends CI_Model { 'metric' => xss_clean($this->input->post('measurementType', true)), 'width' => xss_clean($this->input->post('width', true)), 'height' => xss_clean($this->input->post('height', true)), + 'orientation' => xss_clean($this->input->post('orientation', true)), 'last_modified' => date('Y-m-d H:i:s'), ); @@ -182,6 +183,7 @@ class Labels_model extends CI_Model { 'metric' => xss_clean($this->input->post('measurementType', true)), 'width' => xss_clean($this->input->post('width', true)), 'height' => xss_clean($this->input->post('height', true)), + 'orientation' => xss_clean($this->input->post('orientation', true)), 'last_modified' => date('Y-m-d H:i:s'), ); diff --git a/application/views/labels/createpaper.php b/application/views/labels/createpaper.php index 91d47a0b..ee721d98 100644 --- a/application/views/labels/createpaper.php +++ b/application/views/labels/createpaper.php @@ -33,6 +33,8 @@
+ +
@@ -45,6 +47,17 @@ Total height of paper
+
+ +
+ +
+ + Orientation of paper +
diff --git a/application/views/labels/editpaper.php b/application/views/labels/editpaper.php index 8bb02108..cddfb59a 100644 --- a/application/views/labels/editpaper.php +++ b/application/views/labels/editpaper.php @@ -47,6 +47,17 @@ +
+ +
+ + Orientation of paper +
+
+ From 6cdb88d26d16fa4d817c82bf57b6f9e27b13c7b8 Mon Sep 17 00:00:00 2001 From: int2001 Date: Wed, 2 Aug 2023 11:05:27 +0000 Subject: [PATCH 13/29] Added default papers to migration-script --- .../133_create_label_paper_types_table.php | 90 ++++++++++--------- 1 file changed, 47 insertions(+), 43 deletions(-) diff --git a/application/migrations/133_create_label_paper_types_table.php b/application/migrations/133_create_label_paper_types_table.php index 2146b98c..f8ef690b 100644 --- a/application/migrations/133_create_label_paper_types_table.php +++ b/application/migrations/133_create_label_paper_types_table.php @@ -5,59 +5,63 @@ defined('BASEPATH') OR exit('No direct script access allowed'); class Migration_create_label_paper_types_table extends CI_Migration { public function up() { - if (!$this->db->table_exists('paper_types')) { - $this->dbforge->add_field(array( - 'id' => array( - 'type' => 'INT', - 'constraint' => 5, - 'unsigned' => TRUE, - 'auto_increment' => TRUE - ), + if (!$this->db->table_exists('paper_types')) { + $this->dbforge->add_field(array( + 'id' => array( + 'type' => 'INT', + 'constraint' => 5, + 'unsigned' => TRUE, + 'auto_increment' => TRUE + ), - 'user_id' => array( - 'type' => 'INT', - 'constraint' => 5, - ), + 'user_id' => array( + 'type' => 'INT', + 'constraint' => 5, + ), - 'paper_name' => array( - 'type' => 'VARCHAR', - 'constraint' => '250', - ), + 'paper_name' => array( + 'type' => 'VARCHAR', + 'constraint' => '250', + ), 'metric' => array( - 'type' => 'VARCHAR', - 'constraint' => '10', - ), + 'type' => 'VARCHAR', + 'constraint' => '10', + ), - 'width' => array( - 'type' => 'DECIMAL', - 'constraint' => '6,3', - 'null' => TRUE, - ), + 'width' => array( + 'type' => 'DECIMAL', + 'constraint' => '6,3', + 'null' => TRUE, + ), - 'orientation' => array( - 'type' => 'VARCHAR', - 'constraint' => '1', - 'null' => TRUE, - ), + 'orientation' => array( + 'type' => 'VARCHAR', + 'constraint' => '1', + 'null' => TRUE, + ), - 'height' => array( - 'type' => 'DECIMAL', - 'constraint' => '6,3', - 'null' => TRUE, - ), + 'height' => array( + 'type' => 'DECIMAL', + 'constraint' => '6,3', + 'null' => TRUE, + ), - 'last_modified' => array( - 'type' => 'timestamp', - 'null' => TRUE, - ), - )); + 'last_modified' => array( + 'type' => 'timestamp', + 'null' => TRUE, + ), + )); - $this->dbforge->add_key('id', TRUE); - $this->dbforge->add_key('user_id', TRUE); + $this->dbforge->add_key('id', TRUE); + $this->dbforge->add_key('user_id', TRUE); - $this->dbforge->create_table('paper_types'); - } + $this->dbforge->create_table('paper_types'); + $this->db->query("insert into paper_types (id,user_id,paper_name,metric,width,orientation,height) values ('1','1','A4','mm','210.000','P','297.000');"); + $this->db->query("insert into paper_types (id,user_id,paper_name,metric,width,orientation,height) values ('2','1','A5','mm','148.000','P','210.000');"); + $this->db->query("insert into paper_types (id,user_id,paper_name,metric,width,orientation,height) values ('3','1','letter','mm','215.900','P','279.400');"); + $this->db->query("insert ignore paper_types (user_id,paper_name,metric,width,orientation,height) SELECT u.user_id, pt.paper_name, pt.metric, pt.width, pt.orientation,pt.height FROM paper_types pt inner join users u where pt.id<4;"); + } } From d0f919f26aa8c2cae9d8a191ee65f44fadb7baf0 Mon Sep 17 00:00:00 2001 From: int2001 Date: Wed, 2 Aug 2023 11:05:44 +0000 Subject: [PATCH 14/29] Added Default Papers when adding new user --- application/models/User_model.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/models/User_model.php b/application/models/User_model.php index dc9eff52..fe6ea4e7 100644 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -172,6 +172,7 @@ class User_Model extends CI_Model { $this->db->insert($this->config->item('auth_table'), $data); $insert_id = $this->db->insert_id(); $this->db->query("insert into bandxuser (bandid, userid, active, cq, dok, dxcc, iota, pota, sig, sota, uscounties, was, wwff, vucc) select bands.id, " . $insert_id . ", 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 from bands;"); + $this->db->query("insert into paper_types (user_id,paper_name,metric,width,orientation,height) SELECT ".$insert_id.", paper_name, metric, width, orientation,height FROM paper_types where id<4;"); return OK; } else { return EUSERNAMEEXISTS; From 84833803af06131cca5c624d91eaa421508311c7 Mon Sep 17 00:00:00 2001 From: int2001 Date: Wed, 2 Aug 2023 11:18:58 +0000 Subject: [PATCH 15/29] Added Index to migration-script --- application/migrations/133_create_label_paper_types_table.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/migrations/133_create_label_paper_types_table.php b/application/migrations/133_create_label_paper_types_table.php index f8ef690b..58d8571c 100644 --- a/application/migrations/133_create_label_paper_types_table.php +++ b/application/migrations/133_create_label_paper_types_table.php @@ -57,6 +57,7 @@ class Migration_create_label_paper_types_table extends CI_Migration { $this->dbforge->add_key('user_id', TRUE); $this->dbforge->create_table('paper_types'); + $this->db->query("CREATE UNIQUE INDEX idx_paper_types_user_id_paper_name ON paper_types (user_id, paper_name) ALGORITHM DEFAULT LOCK DEFAULT;"); $this->db->query("insert into paper_types (id,user_id,paper_name,metric,width,orientation,height) values ('1','1','A4','mm','210.000','P','297.000');"); $this->db->query("insert into paper_types (id,user_id,paper_name,metric,width,orientation,height) values ('2','1','A5','mm','148.000','P','210.000');"); $this->db->query("insert into paper_types (id,user_id,paper_name,metric,width,orientation,height) values ('3','1','letter','mm','215.900','P','279.400');"); From abb89aa473e118c1472eab733ca67e0793e125fd Mon Sep 17 00:00:00 2001 From: int2001 Date: Wed, 2 Aug 2023 16:24:45 +0000 Subject: [PATCH 16/29] Adjusted mig-scripts --- application/config/migration.php | 2 +- ...r_types_table.php => 134_create_label_paper_types_table.php} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename application/migrations/{133_create_label_paper_types_table.php => 134_create_label_paper_types_table.php} (100%) diff --git a/application/config/migration.php b/application/config/migration.php index 6a1ed952..a700f85d 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE; | */ -$config['migration_version'] = 133; +$config['migration_version'] = 134; /* |-------------------------------------------------------------------------- diff --git a/application/migrations/133_create_label_paper_types_table.php b/application/migrations/134_create_label_paper_types_table.php similarity index 100% rename from application/migrations/133_create_label_paper_types_table.php rename to application/migrations/134_create_label_paper_types_table.php From e0977ea3d71944d1e0384d11ed3524c34b3b9151 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 2 Aug 2023 18:25:04 +0200 Subject: [PATCH 17/29] Updated script number --- application/config/migration.php | 2 +- ...r_types_table.php => 134_create_label_paper_types_table.php} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename application/migrations/{133_create_label_paper_types_table.php => 134_create_label_paper_types_table.php} (100%) diff --git a/application/config/migration.php b/application/config/migration.php index 6a1ed952..a700f85d 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE; | */ -$config['migration_version'] = 133; +$config['migration_version'] = 134; /* |-------------------------------------------------------------------------- diff --git a/application/migrations/133_create_label_paper_types_table.php b/application/migrations/134_create_label_paper_types_table.php similarity index 100% rename from application/migrations/133_create_label_paper_types_table.php rename to application/migrations/134_create_label_paper_types_table.php From d1d602a941a7d07755176d5f69b57783d87d15a6 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 2 Aug 2023 19:10:35 +0200 Subject: [PATCH 18/29] Added error message when saving or editing a paper type with duplicate name --- application/controllers/Labels.php | 16 +++++++++++++--- application/views/labels/createpaper.php | 20 ++++++++++++++++---- application/views/labels/editpaper.php | 18 ++++++++++++++++-- 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index 97ca48b5..15029d49 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -118,8 +118,12 @@ class Labels extends CI_Controller { else { $this->load->model('labels_model'); - $this->labels_model->addPaper(); - + try { + $this->labels_model->addPaper(); + } catch (\Throwable $th) { + $this->session->set_flashdata('error', 'Your paper could not be saved. Remember that it can\'t have the same name as existing paper types.'); + redirect('labels/createpaper'); + } redirect('labels'); } @@ -379,7 +383,13 @@ class Labels extends CI_Controller { public function updatePaper($id) { $this->load->model('labels_model'); - $this->labels_model->updatePaper($id); + try { + $this->labels_model->updatePaper($id); + } catch (\Throwable $th) { + $this->session->set_flashdata('error', 'Your paper could not be saved. Remember that it can\'t have the same name as existing paper types.'); + $cleanid = $this->security->xss_clean($id); + redirect('labels/editpaper/'.$cleanid); + } $this->session->set_flashdata('message', 'Paper was saved.'); redirect('labels'); } diff --git a/application/views/labels/createpaper.php b/application/views/labels/createpaper.php index ee721d98..6bc3f285 100644 --- a/application/views/labels/createpaper.php +++ b/application/views/labels/createpaper.php @@ -3,8 +3,22 @@
session->flashdata('message')) { ?> -
-

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

+ + + + session->flashdata('error')) { ?> + + + + + session->flashdata('warning')) { ?> + + @@ -33,8 +47,6 @@
- -
diff --git a/application/views/labels/editpaper.php b/application/views/labels/editpaper.php index cddfb59a..f7de1553 100644 --- a/application/views/labels/editpaper.php +++ b/application/views/labels/editpaper.php @@ -3,8 +3,22 @@
session->flashdata('message')) { ?> -
-

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

+ + + + session->flashdata('error')) { ?> + + + + + session->flashdata('warning')) { ?> + + From c57c636068b24c6c8bee091c97d1eba5ae3adbf7 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 2 Aug 2023 19:14:18 +0200 Subject: [PATCH 19/29] Changed paper type templates to have user_id -1 --- .../migrations/134_create_label_paper_types_table.php | 8 ++++---- application/models/User_model.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/application/migrations/134_create_label_paper_types_table.php b/application/migrations/134_create_label_paper_types_table.php index 58d8571c..70db4bad 100644 --- a/application/migrations/134_create_label_paper_types_table.php +++ b/application/migrations/134_create_label_paper_types_table.php @@ -58,10 +58,10 @@ class Migration_create_label_paper_types_table extends CI_Migration { $this->dbforge->create_table('paper_types'); $this->db->query("CREATE UNIQUE INDEX idx_paper_types_user_id_paper_name ON paper_types (user_id, paper_name) ALGORITHM DEFAULT LOCK DEFAULT;"); - $this->db->query("insert into paper_types (id,user_id,paper_name,metric,width,orientation,height) values ('1','1','A4','mm','210.000','P','297.000');"); - $this->db->query("insert into paper_types (id,user_id,paper_name,metric,width,orientation,height) values ('2','1','A5','mm','148.000','P','210.000');"); - $this->db->query("insert into paper_types (id,user_id,paper_name,metric,width,orientation,height) values ('3','1','letter','mm','215.900','P','279.400');"); - $this->db->query("insert ignore paper_types (user_id,paper_name,metric,width,orientation,height) SELECT u.user_id, pt.paper_name, pt.metric, pt.width, pt.orientation,pt.height FROM paper_types pt inner join users u where pt.id<4;"); + $this->db->query("insert into paper_types (id,user_id,paper_name,metric,width,orientation,height) values ('1','-1','A4','mm','210.000','P','297.000');"); + $this->db->query("insert into paper_types (id,user_id,paper_name,metric,width,orientation,height) values ('2','-1','A5','mm','148.000','P','210.000');"); + $this->db->query("insert into paper_types (id,user_id,paper_name,metric,width,orientation,height) values ('3','-1','letter','mm','215.900','P','279.400');"); + $this->db->query("insert ignore paper_types (user_id,paper_name,metric,width,orientation,height) SELECT u.user_id, pt.paper_name, pt.metric, pt.width, pt.orientation,pt.height FROM paper_types pt inner join users u where pt.user_id = -1;"); } } diff --git a/application/models/User_model.php b/application/models/User_model.php index ba8a1151..fe84a0c9 100644 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -173,7 +173,7 @@ class User_Model extends CI_Model { $this->db->insert($this->config->item('auth_table'), $data); $insert_id = $this->db->insert_id(); $this->db->query("insert into bandxuser (bandid, userid, active, cq, dok, dxcc, iota, pota, sig, sota, uscounties, was, wwff, vucc) select bands.id, " . $insert_id . ", 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 from bands;"); - $this->db->query("insert into paper_types (user_id,paper_name,metric,width,orientation,height) SELECT ".$insert_id.", paper_name, metric, width, orientation,height FROM paper_types where id<4;"); + $this->db->query("insert into paper_types (user_id,paper_name,metric,width,orientation,height) SELECT ".$insert_id.", paper_name, metric, width, orientation,height FROM paper_types where user_id = -1;"); return OK; } else { return EUSERNAMEEXISTS; From 6d2c4b1b76708ea7423de10609d6d306a3385e67 Mon Sep 17 00:00:00 2001 From: int2001 Date: Thu, 3 Aug 2023 04:37:25 +0000 Subject: [PATCH 20/29] Switched from paper_name to paper_id --- application/controllers/Labels.php | 2 +- .../134_create_label_paper_types_table.php | 12 +++++----- application/models/Labels_model.php | 22 ++++++++++--------- application/views/labels/create.php | 6 ++--- application/views/labels/edit.php | 8 +++---- application/views/labels/editpaper.php | 2 +- application/views/labels/index.php | 8 +++---- 7 files changed, 32 insertions(+), 28 deletions(-) diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index 15029d49..defd0db5 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -161,7 +161,7 @@ class Labels extends CI_Controller { try { if ($label) { - $ptype=$this->labels_model->getPaperType($label->paper_type); // fetch papersize out of paper-table + $ptype=$this->labels_model->getPaperType($label->paper_type_id); // fetch papersize out of paper-table // var_dump($ptype); $pdf = new PDF_Label(array( 'paper-size' => 'custom', // $label->paper_type, // The only Type left is "custom" because A4 and so on are also defined at paper_types diff --git a/application/migrations/134_create_label_paper_types_table.php b/application/migrations/134_create_label_paper_types_table.php index 70db4bad..5583a6f9 100644 --- a/application/migrations/134_create_label_paper_types_table.php +++ b/application/migrations/134_create_label_paper_types_table.php @@ -7,7 +7,7 @@ class Migration_create_label_paper_types_table extends CI_Migration { public function up() { if (!$this->db->table_exists('paper_types')) { $this->dbforge->add_field(array( - 'id' => array( + 'paper_id' => array( 'type' => 'INT', 'constraint' => 5, 'unsigned' => TRUE, @@ -53,15 +53,17 @@ class Migration_create_label_paper_types_table extends CI_Migration { ), )); - $this->dbforge->add_key('id', TRUE); + $this->dbforge->add_key('paper_id', TRUE); $this->dbforge->add_key('user_id', TRUE); $this->dbforge->create_table('paper_types'); + $this->db->query("ALTER TABLE label_types ADD COLUMN paper_type_id INT(5) NOT NULL;"); $this->db->query("CREATE UNIQUE INDEX idx_paper_types_user_id_paper_name ON paper_types (user_id, paper_name) ALGORITHM DEFAULT LOCK DEFAULT;"); - $this->db->query("insert into paper_types (id,user_id,paper_name,metric,width,orientation,height) values ('1','-1','A4','mm','210.000','P','297.000');"); - $this->db->query("insert into paper_types (id,user_id,paper_name,metric,width,orientation,height) values ('2','-1','A5','mm','148.000','P','210.000');"); - $this->db->query("insert into paper_types (id,user_id,paper_name,metric,width,orientation,height) values ('3','-1','letter','mm','215.900','P','279.400');"); + $this->db->query("insert into paper_types (paper_id,user_id,paper_name,metric,width,orientation,height) values ('1','-1','A4','mm','210.000','P','297.000');"); + $this->db->query("insert into paper_types (paper_id,user_id,paper_name,metric,width,orientation,height) values ('2','-1','A5','mm','148.000','P','210.000');"); + $this->db->query("insert into paper_types (paper_id,user_id,paper_name,metric,width,orientation,height) values ('3','-1','letter','mm','215.900','P','279.400');"); $this->db->query("insert ignore paper_types (user_id,paper_name,metric,width,orientation,height) SELECT u.user_id, pt.paper_name, pt.metric, pt.width, pt.orientation,pt.height FROM paper_types pt inner join users u where pt.user_id = -1;"); + $this->db->query("update label_types l set l.paper_type_id=(select p.paper_id from paper_types p where upper(p.paper_name)=upper(l.paper_type) and p.user_id=l.user_id limit 1) where l.paper_type_id=0;"); } } diff --git a/application/models/Labels_model.php b/application/models/Labels_model.php index ac2c3e61..18854020 100644 --- a/application/models/Labels_model.php +++ b/application/models/Labels_model.php @@ -5,7 +5,7 @@ class Labels_model extends CI_Model { $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)), + 'paper_type_id' => xss_clean($this->input->post('paper_type_id', 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)), @@ -41,8 +41,9 @@ class Labels_model extends CI_Model { } function getLabel($id) { - $this->db->where('user_id', $this->session->userdata('user_id')); - $this->db->where('id', $id); + $this->db->join('paper_types', 'paper_types.paper_id = label_types.paper_type_id'); + $this->db->where('label_types.user_id', $this->session->userdata('user_id')); + $this->db->where('label_types.id', $id); $query = $this->db->get('label_types'); return $query->row(); @@ -52,7 +53,7 @@ class Labels_model extends CI_Model { $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)), + 'paper_type_id' => xss_clean($this->input->post('paper_type_id', 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)), @@ -82,7 +83,8 @@ class Labels_model extends CI_Model { } function fetchLabels($user_id) { - $this->db->where('user_id', $user_id); + $this->db->join('paper_types', 'paper_types.paper_id = label_types.paper_type_id'); + $this->db->where('label_types.user_id', $user_id); $query = $this->db->get('label_types'); return $query->result(); @@ -118,9 +120,9 @@ class Labels_model extends CI_Model { return $query->row(); } - function getPaperType($ptype) { + function getPaperType($ptype_id) { $this->db->where('user_id', $this->session->userdata('user_id')); - $this->db->where('paper_name',$ptype); + $this->db->where('paper_id',$ptype_id); $query = $this->db->get('paper_types'); return $query->row(); @@ -190,19 +192,19 @@ class Labels_model extends CI_Model { $cleanid = $this->security->xss_clean($id); $this->db->where('user_id', $this->session->userdata('user_id')); - $this->db->where('id', $cleanid); + $this->db->where('paper_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'))); + $this->db->delete('paper_types', array('paper_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); + $this->db->where('paper_id', $id); $query = $this->db->get('paper_types'); return $query->row(); diff --git a/application/views/labels/create.php b/application/views/labels/create.php index 9a074008..8b0fc017 100644 --- a/application/views/labels/create.php +++ b/application/views/labels/create.php @@ -25,12 +25,12 @@
- +
- paper_name . '>' . ucwords(strtolower(($paper->paper_name))) . ''; + echo ''; } ?> diff --git a/application/views/labels/edit.php b/application/views/labels/edit.php index ec509cdf..6483a63f 100644 --- a/application/views/labels/edit.php +++ b/application/views/labels/edit.php @@ -25,13 +25,13 @@
- +
- paper_name . '"'; - if ($label->paper_type == $paper->paper_name) echo ' selected'; + echo ''; } ?> diff --git a/application/views/labels/editpaper.php b/application/views/labels/editpaper.php index f7de1553..b6980a53 100644 --- a/application/views/labels/editpaper.php +++ b/application/views/labels/editpaper.php @@ -24,7 +24,7 @@ - +

diff --git a/application/views/labels/index.php b/application/views/labels/index.php index 73375454..c2fc1782 100644 --- a/application/views/labels/index.php +++ b/application/views/labels/index.php @@ -46,14 +46,14 @@
- + - - + + - + From 9aa82ad3af8516afb75996e7cdfab3f354a2e812 Mon Sep 17 00:00:00 2001 From: int2001 Date: Thu, 3 Aug 2023 04:42:51 +0000 Subject: [PATCH 21/29] drop old col paper_type after migration from label_types --- application/migrations/134_create_label_paper_types_table.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/migrations/134_create_label_paper_types_table.php b/application/migrations/134_create_label_paper_types_table.php index 5583a6f9..afc9c4ff 100644 --- a/application/migrations/134_create_label_paper_types_table.php +++ b/application/migrations/134_create_label_paper_types_table.php @@ -64,6 +64,7 @@ class Migration_create_label_paper_types_table extends CI_Migration { $this->db->query("insert into paper_types (paper_id,user_id,paper_name,metric,width,orientation,height) values ('3','-1','letter','mm','215.900','P','279.400');"); $this->db->query("insert ignore paper_types (user_id,paper_name,metric,width,orientation,height) SELECT u.user_id, pt.paper_name, pt.metric, pt.width, pt.orientation,pt.height FROM paper_types pt inner join users u where pt.user_id = -1;"); $this->db->query("update label_types l set l.paper_type_id=(select p.paper_id from paper_types p where upper(p.paper_name)=upper(l.paper_type) and p.user_id=l.user_id limit 1) where l.paper_type_id=0;"); + $this->db->query("alter table label_types drop column paper_type;"); } } From 262cca54656c780a3704aaad7f1b417bbbbc6812 Mon Sep 17 00:00:00 2001 From: int2001 Date: Thu, 3 Aug 2023 06:15:51 +0000 Subject: [PATCH 22/29] Added orientation and usage count to view/controller/model --- application/controllers/Labels.php | 5 +++++ application/models/Labels_model.php | 19 +++++++++++++++---- application/views/labels/index.php | 4 ++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index defd0db5..314108ba 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -394,6 +394,11 @@ class Labels extends CI_Controller { redirect('labels'); } + function label_cnt_with_paper($paper_id) { + $this->load->model('labels_model'); + return $this->labels_model->label_cnt_with_paper($paper_id); + } + public function deletePaper($id) { $this->load->model('labels_model'); $this->labels_model->deletePaper($id); diff --git a/application/models/Labels_model.php b/application/models/Labels_model.php index 18854020..dcd6d374 100644 --- a/application/models/Labels_model.php +++ b/application/models/Labels_model.php @@ -91,10 +91,9 @@ class Labels_model extends CI_Model { } function fetchPapertypes($user_id) { - $this->db->where('user_id', $user_id); - $query = $this->db->get('paper_types'); - - return $query->result(); + $sql="SELECT p.paper_id,p.user_id,p.paper_name,p.metric,p.width,p.height,p.last_modified, p.orientation,COUNT(DISTINCT l.id) AS lbl_cnt FROM paper_types p LEFT OUTER JOIN label_types l ON (p.paper_id = l.paper_type_id and p.user_id=l.user_id) WHERE p.user_id = ? group by p.paper_id,p.user_id,p.paper_name,p.metric,p.width,p.height,p.last_modified;"; + $query = $this->db->query($sql, $this->session->userdata('user_id')); + return $query->result(); } function fetchQsos($user_id) { @@ -196,6 +195,18 @@ class Labels_model extends CI_Model { $this->db->update('paper_types', $data); } + function label_cnt_with_paper($paper_id) { + $clean_paper_id=xss_clean($paper_id); + $sql="select count(distinct l.id) as CNT from label_types l inner join paper_types p on (p.paper_id=l.paper_type_id) where l.user_id=? and p.user_id=? and l.paper_type_id=?"; + $query = $this->db->query($sql, array($this->session->userdata('user_id'), this->session->userdata('user_id'), $clean_paper_id)); + $row = $query->row(); + if (isset($row)) { + return($row->CNT); + } else { + return 0; + } + } + function deletePaper($id) { $cleanid = xss_clean($id); diff --git a/application/views/labels/index.php b/application/views/labels/index.php index c2fc1782..96c60119 100644 --- a/application/views/labels/index.php +++ b/application/views/labels/index.php @@ -38,7 +38,9 @@ + + @@ -51,7 +53,9 @@ + + From 95dda89fc622911eeff37dab62e72a2bad799a55 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Thu, 3 Aug 2023 08:16:13 +0200 Subject: [PATCH 23/29] Updated migration script to update on down, and failsafe for papertype --- .../134_create_label_paper_types_table.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/application/migrations/134_create_label_paper_types_table.php b/application/migrations/134_create_label_paper_types_table.php index afc9c4ff..6159628e 100644 --- a/application/migrations/134_create_label_paper_types_table.php +++ b/application/migrations/134_create_label_paper_types_table.php @@ -64,6 +64,7 @@ class Migration_create_label_paper_types_table extends CI_Migration { $this->db->query("insert into paper_types (paper_id,user_id,paper_name,metric,width,orientation,height) values ('3','-1','letter','mm','215.900','P','279.400');"); $this->db->query("insert ignore paper_types (user_id,paper_name,metric,width,orientation,height) SELECT u.user_id, pt.paper_name, pt.metric, pt.width, pt.orientation,pt.height FROM paper_types pt inner join users u where pt.user_id = -1;"); $this->db->query("update label_types l set l.paper_type_id=(select p.paper_id from paper_types p where upper(p.paper_name)=upper(l.paper_type) and p.user_id=l.user_id limit 1) where l.paper_type_id=0;"); + $this->db->query("update label_types l set l.paper_type_id = (select p.paper_id from paper_types p where p.user_id = l.user_id limit 1) where l.paper_type_id = 0;"); $this->db->query("alter table label_types drop column paper_type;"); } @@ -73,5 +74,18 @@ class Migration_create_label_paper_types_table extends CI_Migration { if ($this->db->table_exists('paper_types')) { $this->dbforge->drop_table('paper_types'); } + + if ($this->db->field_exists('paper_type_id', 'label_types')) { + $this->dbforge->drop_column('label_types', 'paper_type_id'); + } + + if (!$this->db->field_exists('paper_type', 'label_types')) { + $fields = array( + 'paper_type varchar(250)', + ); + + $this->dbforge->add_column('label_types', $fields); + $this->db->query("update label_types set paper_type = 'a4';"); + } } } From 85a229932230b1380a196b98d716fa0f8ae0a67b Mon Sep 17 00:00:00 2001 From: int2001 Date: Thu, 3 Aug 2023 06:53:22 +0000 Subject: [PATCH 24/29] Added warning if no paper_type is assigned --- application/controllers/Labels.php | 2 +- application/models/Labels_model.php | 19 ++++++++----------- application/views/labels/edit.php | 6 +++--- application/views/labels/index.php | 2 +- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index 314108ba..b1c05642 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -331,7 +331,7 @@ class Labels extends CI_Controller { $cleanid = $this->security->xss_clean($id); - $data['label'] = $this->labels_model->getLabel($cleanid); + $data['label'] = $this->labels_model->getLabel($cleanid,$this->session->userdata('user_id')); $data['papertypes'] = $this->labels_model->fetchPapertypes($this->session->userdata('user_id')); diff --git a/application/models/Labels_model.php b/application/models/Labels_model.php index dcd6d374..ad80dff3 100644 --- a/application/models/Labels_model.php +++ b/application/models/Labels_model.php @@ -40,14 +40,13 @@ class Labels_model extends CI_Model { } - function getLabel($id) { - $this->db->join('paper_types', 'paper_types.paper_id = label_types.paper_type_id'); - $this->db->where('label_types.user_id', $this->session->userdata('user_id')); - $this->db->where('label_types.id', $id); - $query = $this->db->get('label_types'); + function getLabel($id,$user_id) { + $sql="SELECT l.id, l.user_id,l.label_name, p.paper_name, p.paper_id,l.paper_type_id,l.metric, l.marginleft, l.margintop, l.nx, l.ny, l.spacex, l.spacey, l.width, l.height, l.font_size, l.font, l.qsos, l.useforprint, l.last_modified FROM cloudlog.label_types l left outer join paper_types p on (p.user_id=l.user_id and p.paper_id=l.paper_type_id) where l.user_id=? and l.id=?;"; + $query=$this->db->query($sql,array($user_id,$id)); + $result=$query->result(); + return $result[0]; + } - return $query->row(); - } function updateLabel($id) { $data = array( @@ -83,10 +82,8 @@ class Labels_model extends CI_Model { } function fetchLabels($user_id) { - $this->db->join('paper_types', 'paper_types.paper_id = label_types.paper_type_id'); - $this->db->where('label_types.user_id', $user_id); - $query = $this->db->get('label_types'); - + $sql="SELECT l.id, l.user_id,l.label_name, p.paper_name, l.metric, l.marginleft, l.margintop, l.nx, l.ny, l.spacex, l.spacey, l.width, l.height, l.font_size, l.font, l.qsos, l.useforprint, l.last_modified FROM cloudlog.label_types l left outer join paper_types p on (p.user_id=l.user_id and p.paper_id=l.paper_type_id) where l.user_id=?;"; + $query=$this->db->query($sql,$user_id); return $query->result(); } diff --git a/application/views/labels/edit.php b/application/views/labels/edit.php index 6483a63f..101fb2c2 100644 --- a/application/views/labels/edit.php +++ b/application/views/labels/edit.php @@ -30,9 +30,9 @@ diff --git a/application/views/labels/index.php b/application/views/labels/index.php index 96c60119..b6f15b18 100644 --- a/application/views/labels/index.php +++ b/application/views/labels/index.php @@ -88,7 +88,7 @@ foreach($labels as $label) { ?> - + From 2824f31ac6a4f0271ad362ae349251b406551e3f Mon Sep 17 00:00:00 2001 From: int2001 Date: Thu, 3 Aug 2023 08:55:16 +0000 Subject: [PATCH 25/29] Disabled "use for print" if no paper given, catching error if those label was active --- application/controllers/Labels.php | 44 ++++++++++++++++++------------ application/views/labels/index.php | 4 +++ 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index b1c05642..d393be90 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -162,22 +162,32 @@ class Labels extends CI_Controller { try { if ($label) { $ptype=$this->labels_model->getPaperType($label->paper_type_id); // fetch papersize out of paper-table - // var_dump($ptype); - $pdf = new PDF_Label(array( - 'paper-size' => 'custom', // $label->paper_type, // The only Type left is "custom" because A4 and so on are also defined at paper_types - 'metric' => $label->metric, - 'marginLeft' => $label->marginleft, - 'marginTop' => $label->margintop, - 'NX' => $label->nx, - 'NY' => $label->ny, - 'SpaceX' => $label->spacex, - 'SpaceY' => $label->spacey, - 'width' => $label->width, - 'height' => $label->height, - 'font-size' => $label->font_size, - 'pgX' => $ptype->width, - 'pgY' => $ptype->height - )); + if (($ptype->paper_id ?? '') != '') { + $pdf = new PDF_Label(array( + 'paper-size' => 'custom', // $label->paper_type, // The only Type left is "custom" because A4 and so on are also defined at paper_types + 'metric' => $label->metric, + 'marginLeft' => $label->marginleft, + 'marginTop' => $label->margintop, + 'NX' => $label->nx, + 'NY' => $label->ny, + 'SpaceX' => $label->spacex, + 'SpaceY' => $label->spacey, + 'width' => $label->width, + 'height' => $label->height, + 'font-size' => $label->font_size, + 'pgX' => $ptype->width, + 'pgY' => $ptype->height + )); + } else { + if ($jscall) { + header('Content-Type: application/json'); + echo json_encode(array('message' => 'You need to assign a paperType to the label before printing')); + return; + } else { + $this->session->set_flashdata('error', 'You need to assign a paperType to the label before printing'); + redirect('labels'); + } + } } else { if ($jscall) { header('Content-Type: application/json'); @@ -204,7 +214,7 @@ class Labels extends CI_Controller { if ($label->font == 'DejaVuSans') { // leave this here, for future Use $pdf->AddFont($label->font,'','DejaVuSansMono.ttf',true); - $pdf->SetFont($label->font); + $pdf->SetFont($label->font,''); } else { $pdf->AddFont($label->font); $pdf->SetFont($label->font); diff --git a/application/views/labels/index.php b/application/views/labels/index.php index b6f15b18..6f4ad7f1 100644 --- a/application/views/labels/index.php +++ b/application/views/labels/index.php @@ -95,7 +95,11 @@ + paper_name ?? '') == '') { ?> + + + From 2db344d220ad204e5cb5c7b6c35920c9d66173be Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Thu, 3 Aug 2023 12:27:17 +0200 Subject: [PATCH 26/29] Removed last modified. Also shows portrait/landscape in table --- application/views/labels/index.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/application/views/labels/index.php b/application/views/labels/index.php index b6f15b18..eeaf3d6f 100644 --- a/application/views/labels/index.php +++ b/application/views/labels/index.php @@ -39,7 +39,6 @@ - @@ -54,8 +53,7 @@ - - + @@ -77,7 +75,6 @@ - @@ -94,7 +91,6 @@ - From 126d781baa014854a413a5a8649030a74ca53cda Mon Sep 17 00:00:00 2001 From: int2001 Date: Thu, 3 Aug 2023 11:15:02 +0000 Subject: [PATCH 27/29] Added Station-ID to label-qso-view --- application/controllers/Qslprint.php | 9 +++++++-- application/views/labels/index.php | 2 +- application/views/qslprint/index.php | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/application/controllers/Qslprint.php b/application/controllers/Qslprint.php index 72b08c19..4f7f0b23 100644 --- a/application/controllers/Qslprint.php +++ b/application/controllers/Qslprint.php @@ -17,7 +17,7 @@ class QSLPrint extends CI_Controller { } } - public function index() + public function index($station_id = 'All') { $this->load->model('user_model'); @@ -28,10 +28,15 @@ class QSLPrint extends CI_Controller { redirect('user/login'); } $this->load->model('stations'); + $data['station_id'] = $this->security->xss_clean($station_id); $data['station_profile'] = $this->stations->all_of_user(); $this->load->model('qslprint_model'); - $data['qsos'] = $this->qslprint_model->get_qsos_for_print(); + if ( ($station_id != 'All') && ($this->stations->check_station_is_accessible($station_id)) ) { + $data['qsos'] = $this->qslprint_model->get_qsos_for_print($station_id); + } else { + $data['qsos'] = $this->qslprint_model->get_qsos_for_print(); + } $data['page_title'] = "Print Requested QSLs"; diff --git a/application/views/labels/index.php b/application/views/labels/index.php index 23941b79..7f8755d6 100644 --- a/application/views/labels/index.php +++ b/application/views/labels/index.php @@ -131,7 +131,7 @@ echo ''; echo ''; echo ''; - echo ''; + echo ''; echo ''; echo ''; } ?> diff --git a/application/views/qslprint/index.php b/application/views/qslprint/index.php index 64c3de6c..e8c435fe 100644 --- a/application/views/qslprint/index.php +++ b/application/views/qslprint/index.php @@ -21,7 +21,7 @@ @@ -37,4 +37,4 @@ - \ No newline at end of file + From bf858f31de3b6e20911f7f799129fdbb84a38305 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Thu, 3 Aug 2023 13:24:05 +0200 Subject: [PATCH 28/29] Added dialog for delete --- application/views/labels/index.php | 6 ++--- assets/js/sections/labels.js | 38 ++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/application/views/labels/index.php b/application/views/labels/index.php index 7f8755d6..2b2e7422 100644 --- a/application/views/labels/index.php +++ b/application/views/labels/index.php @@ -47,7 +47,7 @@ - + @@ -55,7 +55,7 @@ - + useforprint == 1) {echo 'checked';}?>> - + 0) { + message = 'Warning! This paper type is in use. Are you really sure you want delete this paper type?'; + } + BootstrapDialog.confirm({ + title: 'DANGER', + message: message, + type: BootstrapDialog.TYPE_DANGER, + closable: true, + draggable: true, + btnOKClass: 'btn-danger', + callback: function(result) { + if (result) { + window.location.replace(base_url + 'index.php/labels/deletePaper/'+id); + } + } + }); +} From f5baeb8fa20e74ec6621e2b46b857101eaaa9e4a Mon Sep 17 00:00:00 2001 From: int2001 Date: Thu, 3 Aug 2023 11:34:29 +0000 Subject: [PATCH 29/29] fixed "no active label"-detection --- application/controllers/Labels.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index d393be90..9a81d396 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -156,11 +156,11 @@ class Labels extends CI_Controller { function prepareLabel($qsos, $jscall = false, $offset = 1) { $this->load->model('labels_model'); $label = $this->labels_model->getDefaultLabel(); - $label->font='DejaVuSans'; // Fix font to DejaVuSans try { if ($label) { + $label->font='DejaVuSans'; // Fix font to DejaVuSans $ptype=$this->labels_model->getPaperType($label->paper_type_id); // fetch papersize out of paper-table if (($ptype->paper_id ?? '') != '') { $pdf = new PDF_Label(array(
paper_name; ?> metric; ?> width; ?> height; ?> last_modified; ?>
label_name; ?>paper_type; ?>paper_name; ?> metric; ?> width; ?> height; ?>Measurement Width HeightUsed by labels Last ModifiedOrientation Edit Delete
metric; ?> width; ?> height; ?>lbl_cnt ?? '0' ?> last_modified; ?>orientation; ?>
label_name; ?>paper_name; ?>paper_name ?? 'No paper assigned' ?> metric; ?> width; ?> height; ?>font_size; ?> qsos; ?> last_modified; ?> useforprint == 1) {echo 'checked';}?>>
Width Height Used by labelsLast Modified Orientation Edit Deletewidth; ?> height; ?> lbl_cnt ?? '0' ?>last_modified; ?>orientation; ?>orientation == 'P' ? 'Portrait': 'Landscape'; ?>
Height Font Size QSOsLast Modified Use For Print Edit Deleteheight; ?> font_size; ?> qsos; ?>last_modified; ?> useforprint == 1) {echo 'checked';}?>> ' . $qso->station_profile_name . '' . $qso->station_gridsquare . '' . $qso->count . '
paper_name; ?> metric; ?> width; ?>lbl_cnt ?? '0' ?> orientation == 'P' ? 'Portrait': 'Landscape'; ?>