Merge branch 'labels_paper_types' of https://github.com/AndreasK79/Cloudlog into labels_paper_types

pull/2367/head
Andreas 2023-08-03 08:16:16 +02:00
commit dc7018def0
3 zmienionych plików z 24 dodań i 4 usunięć

Wyświetl plik

@ -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);

Wyświetl plik

@ -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);

Wyświetl plik

@ -38,7 +38,9 @@
<th>Measurement</th>
<th>Width</th>
<th>Height</th>
<th>Used by labels</th>
<th>Last Modified</th>
<th>Orientation</th>
<th>Edit</th>
<th>Delete</th>
</tr>
@ -51,7 +53,9 @@
<td><?php echo $paper->metric; ?></td>
<td><?php echo $paper->width; ?></td>
<td><?php echo $paper->height; ?></td>
<td><?php echo $paper->lbl_cnt ?? '0' ?></td>
<td><?php echo $paper->last_modified; ?></td>
<td><?php echo $paper->orientation; ?></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>