Switched from paper_name to paper_id
这个提交包含在:
父节点
bc62c97c65
当前提交
6d2c4b1b76
共有 7 个文件被更改,包括 32 次插入 和 28 次删除
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -25,12 +25,12 @@
|
|||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-2 col-form-label" for="paperType">Paper Type</label>
|
||||
<label class="col-sm-2 col-form-label" for="paperType_id">Paper Type</label>
|
||||
<div class="col-sm-4">
|
||||
<select name="paper_type" class="form-control" id="paperType">
|
||||
<select name="paper_type_id" class="form-control" id="paperType_id">
|
||||
<?php
|
||||
foreach($papertypes as $paper){
|
||||
echo '<option value=' . $paper->paper_name . '>' . ucwords(strtolower(($paper->paper_name))) . '</option>';
|
||||
echo '<option value=' . $paper->paper_id . '>' . ucwords(strtolower(($paper->paper_name))) . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@
|
|||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-2 col-form-label" for="paperType">Paper Type</label>
|
||||
<label class="col-sm-2 col-form-label" for="paperType_id">Paper Type</label>
|
||||
<div class="col-sm-4">
|
||||
<select name="paper_type" class="form-control" id="paperType">
|
||||
<select name="paper_type_id" class="form-control" id="paperType_id">
|
||||
<?php
|
||||
foreach($papertypes as $paper){
|
||||
echo '<option value="' . $paper->paper_name . '"';
|
||||
if ($label->paper_type == $paper->paper_name) echo ' selected';
|
||||
echo '<option value="' . $paper->paper_id . '"';
|
||||
if ($label->paper_type_id == $paper->paper_id) echo ' selected';
|
||||
echo '>' . ucwords(strtolower(($paper->paper_name))) . '</option>';
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
<?php echo validation_errors(); ?>
|
||||
|
||||
<form method="post" action="<?php echo site_url('labels/updatePaper/' . $paper->id); ?>" name="create_label_type">
|
||||
<form method="post" action="<?php echo site_url('labels/updatePaper/' . $paper->paper_id); ?>" name="create_label_type">
|
||||
|
||||
<div class="card">
|
||||
<h2 class="card-header"><?php echo $page_title; ?></h2>
|
||||
|
|
|
|||
|
|
@ -46,14 +46,14 @@
|
|||
<tbody>
|
||||
<?php
|
||||
foreach($papertypes as $paper) { ?>
|
||||
<tr class='label_<?php echo $paper->id ?>'>
|
||||
<tr class='label_<?php echo $paper->paper_id ?>'>
|
||||
<td><?php echo $paper->paper_name; ?></td>
|
||||
<td><?php echo $paper->metric; ?></td>
|
||||
<td><?php echo $paper->width; ?></td>
|
||||
<td><?php echo $paper->height; ?></td>
|
||||
<td><?php echo $paper->last_modified; ?></td>
|
||||
<td><a href="<?php echo site_url('labels/editpaper/' . $paper->id); ?>" class="btn btn-outline-primary btn-sm"><i class="fas fa-edit"></i></a></td>
|
||||
<td><a href="<?php echo site_url('labels/deletepaper/' . $paper->id); ?>" class="btn btn-outline-danger btn-sm"><i class="fas fa-trash-alt"></i></a></td>
|
||||
<td><a href="<?php echo site_url('labels/editpaper/' . $paper->paper_id); ?>" class="btn btn-outline-primary btn-sm"><i class="fas fa-edit"></i></a></td>
|
||||
<td><a href="<?php echo site_url('labels/deletepaper/' . $paper->paper_id); ?>" class="btn btn-outline-danger btn-sm"><i class="fas fa-trash-alt"></i></a></td>
|
||||
</tr>
|
||||
|
||||
<?php }
|
||||
|
|
@ -84,7 +84,7 @@
|
|||
foreach($labels as $label) { ?>
|
||||
<tr class='label_<?php echo $label->id ?>'>
|
||||
<td><?php echo $label->label_name; ?></td>
|
||||
<td><?php echo $label->paper_type; ?></td>
|
||||
<td><?php echo $label->paper_name; ?></td>
|
||||
<td><?php echo $label->metric; ?></td>
|
||||
<td><?php echo $label->width; ?></td>
|
||||
<td><?php echo $label->height; ?></td>
|
||||
|
|
|
|||
正在加载…
在新工单中引用