[QSL Labels] Added label editing

pull/2199/head
Andreas 2023-06-03 08:46:52 +02:00
rodzic e8eaab8cff
commit f47717bbc1
4 zmienionych plików z 173 dodań i 6 usunięć

Wyświetl plik

@ -145,8 +145,24 @@ class Labels extends CI_Controller {
$pdf->Output();
}
public function edit() {
public function edit($id) {
$this->load->model('labels_model');
$cleanid = $this->security->xss_clean($id);
$data['label'] = $this->labels_model->getLabel($cleanid);
$data['page_title'] = "Edit Label";
$this->load->view('interface_assets/header', $data);
$this->load->view('labels/edit');
$this->load->view('interface_assets/footer');
}
public function updateLabel($id) {
$this->load->model('labels_model');
$this->labels_model->updateLabel($id);
redirect('labels');
}
public function delete($id) {

Wyświetl plik

@ -18,15 +18,44 @@ class Labels_model extends CI_Model {
'font_size' => xss_clean($this->input->post('font_size', true)),
'qsos' => xss_clean($this->input->post('label_qsos', true)),
'last_modified' => date('Y-m-d H:i:s'),
);
$this->db->insert('label_types', $data);
}
function updateLabel() {
function getLabel($id) {
$this->db->where('user_id', $this->session->userdata('user_id'));
$this->db->where('id', $id);
$query = $this->db->get('label_types');
return $query->row();
}
function updateLabel($id) {
$data = array(
'user_id' => $this->session->userdata('user_id'),
'label_name' => xss_clean($this->input->post('label_name', true)),
'paper_type' => xss_clean($this->input->post('paper_type', true)),
'metric' => xss_clean($this->input->post('measurementType', true)),
'marginleft' => xss_clean($this->input->post('marginLeft', true)),
'margintop' => xss_clean($this->input->post('marginTop', true)),
'nx' => xss_clean($this->input->post('NX', true)),
'ny' => xss_clean($this->input->post('NY', true)),
'spacex' => xss_clean($this->input->post('SpaceX', true)),
'spacey' => xss_clean($this->input->post('SpaceY', true)),
'width' => xss_clean($this->input->post('width', true)),
'height' => xss_clean($this->input->post('height', true)),
'font_size' => xss_clean($this->input->post('font_size', true)),
'qsos' => xss_clean($this->input->post('label_qsos', true)),
'last_modified' => date('Y-m-d H:i:s'),
);
$cleanid = $this->security->xss_clean($id);
$this->db->where('user_id', $this->session->userdata('user_id'));
$this->db->where('id', $cleanid);
$this->db->update('label_types', $data);
}
function deleteLabel($id) {

Wyświetl plik

@ -21,7 +21,7 @@
<div class="form-group">
<label for="LabelName">Label Name</label>
<input name="label_name" type="text" class="form-control" id="LabelName" aria-describedby="label_nameHelp" placeholder="Code 925041 6x3 Generic Label Sheet">
<small id="label_nameHelp" class="form-text text-muted">Label name used for display purposes so pick something meaningful perhaps the label style.</small>
<small id="label_nameHelp" class="form-text text-muted">Label name used for display purposes, so pick something meaningful, perhaps the label style.</small>
</div>
<div class="form-group row">
@ -36,7 +36,7 @@
<label class="col-sm-2 col-form-label" for="measurementType">Measurement used</label>
<div class="col-sm-4">
<select name="measurementType" class="form-control" id="measurementType">
<option value="mm">Millimetres</option>
<option value="mm">Millimeters</option>
<option value="in">Inches</option>
</select>
</div>

Wyświetl plik

@ -0,0 +1,122 @@
<div id="qsl_card_labels_container" class="container">
<br>
<?php if($this->session->flashdata('message')) { ?>
<!-- Display Message -->
<div class="alert-message error">
<p><?php echo $this->session->flashdata('message'); ?></p>
</div>
<?php } ?>
<?php echo validation_errors(); ?>
<form method="post" action="<?php echo site_url('labels/updateLabel/' . $label->id); ?>" name="create_label_type">
<div class="card">
<h2 class="card-header"><?php echo $page_title; ?></h2>
<div class="card-body">
<!-- Label Name Input -->
<div class="form-group">
<label for="LabelName">Label Name</label>
<input name="label_name" type="text" class="form-control" id="LabelName" aria-describedby="label_nameHelp" placeholder="Code 925041 6x3 Generic Label Sheet" value="<?php if(isset($label->label_name)) { echo $label->label_name; } ?>">
<small id="label_nameHelp" class="form-text text-muted">Label name used for display purposes so pick something meaningful perhaps the label style.</small>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label" for="paperType">Paper Type</label>
<div class="col-sm-4">
<select name="paper_type" class="form-control" id="paperType">
<option value="a4" <?php if($label->paper_type == "a4") { echo "selected=\"selected\""; } ?>>A4</option>
<option value="letter" <?php if($label->paper_type == "letter") { echo "selected=\"selected\""; } ?>>Letter</option>
</select>
</div>
<label class="col-sm-2 col-form-label" for="measurementType">Measurement used</label>
<div class="col-sm-4">
<select name="measurementType" class="form-control" id="measurementType">
<option value="mm" <?php if($label->metric == "mm") { echo "selected=\"selected\""; } ?>>Millimeters</option>
<option value="in" <?php if($label->metric == "in") { echo "selected=\"selected\""; } ?>>Inches</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label" for="marginTop">Margin Top</label>
<div class="col-sm-4">
<input name="marginTop" type="text" class="form-control" id="marginTop" aria-describedby="marginTopHelp" value="<?php if(isset($label->margintop)) { echo $label->margintop; } ?>">
<small id="marginTopHelp" class="form-text text-muted">Top margin of labels</small>
</div>
<label class="col-sm-2 col-form-label" for="marginLeft">Margin Left</label>
<div class="col-sm-4">
<input name="marginLeft" type="text" class="form-control" id="marginLeft" aria-describedby="marginLeftHelp" value="<?php if(isset($label->marginleft)) { echo $label->marginleft; } ?>">
<small id="marginLeftHelp" class="form-text text-muted">Left margin of labels.</small>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label" for="NX">Labels horizontally</label>
<div class="col-sm-4">
<input name="NX" type="number" min="1" max="40" step="1" class="form-control" id="NX" aria-describedby="NXHelp" value="<?php if(isset($label->nx)) { echo $label->nx; } ?>">
<small id="NXHelp" class="form-text text-muted">Number of labels horizontally across the page.</small>
</div>
<label class="col-sm-2 col-form-label" for="NY">Labels vertically</label>
<div class="col-sm-4">
<input name="NY" type="number" min="1" max="40" step="1" class="form-control" id="NY" aria-describedby="NYHelp" value="<?php if(isset($label->ny)) { echo $label->ny; } ?>">
<small id="NYHelp" class="form-text text-muted">Number of labels vertically across the page.</small>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label" for="SpaceX">Horizontal space</label>
<div class="col-sm-4">
<input name="SpaceX" type="text" class="form-control" id="SpaceX" value="<?php if(isset($label->spacex)) { echo $label->spacex; } ?>">
<small id="NYHelp" class="form-text text-muted">Horizontal space between 2 labels.</small>
</div>
<label class="col-sm-2 col-form-label" for="SpaceY">Vertical space</label>
<div class="col-sm-4">
<input name="SpaceY" type="text" class="form-control" id="SpaceY" value="<?php if(isset($label->spacey)) { echo $label->spacey; } ?>">
<small id="NYHelp" class="form-text text-muted">Vertical space between 2 labels.</small>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label" for="width">Width of label</label>
<div class="col-sm-4">
<input name="width" type="text" class="form-control" id="width" aria-describedby="widthHelp" value="<?php if(isset($label->width)) { echo $label->width; } ?>">
<small id="widthHelp" class="form-text text-muted">Total width of one label.</small>
</div>
<label class="col-sm-2 col-form-label" for="height">Height of label</label>
<div class="col-sm-4">
<input name="height" type="text" class="form-control" id="height" aria-describedby="heightHelp" value="<?php if(isset($label->height)) { echo $label->height; } ?>">
<small id="heightHelp" class="form-text text-muted">Total height of one label</small>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label" for="font_size">Font Size</label>
<div class="col-sm-4">
<input name="font_size" type="number" min="1" max="40" step="1" class="form-control" id="font_size" value="8" aria-describedby="font_sizeHelp" value="<?php if(isset($label->font_size)) { echo $label->font_size; } ?>">
<small id="font_sizeHelp" class="form-text text-muted">Font size used on the label don't go too big.</small>
</div>
<label class="col-sm-2 col-form-label" for="font_size">QSOs on label</label>
<div class="col-sm-4">
<input name="label_qsos" type="number" min="1" max="40" step="1" class="form-control" id="label_qsos" value="5" aria-describedby="font_sizeHelp" value="<?php if(isset($label->qsos)) { echo $label->qsos; } ?>">
</div>
</div>
<button type="submit" class="btn btn-primary"><i class="fas fa-plus-square"></i> Save Label Type</button>
<button type="button" class="btn btn-primary"><i class="fas fa-plus-square"></i> Cancel</button>
</div>
</div>
</form>
</div>
<br>