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('error'); ?>
+
+
+
+ session->flashdata('warning')) { ?>
+
+
+ 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 @@