Added error message when saving or editing a paper type with duplicate name

这个提交包含在:
Andreas 2023-08-02 19:10:35 +02:00
父节点 e0977ea3d7
当前提交 d1d602a941
共有 3 个文件被更改,包括 45 次插入9 次删除

查看文件

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

查看文件

@ -3,8 +3,22 @@
<br>
<?php if($this->session->flashdata('message')) { ?>
<!-- Display Message -->
<div class="alert-message error">
<p><?php echo $this->session->flashdata('message'); ?></p>
<div class="alert alert-success" role="alert">
<?php echo $this->session->flashdata('message'); ?>
</div>
<?php } ?>
<?php if($this->session->flashdata('error')) { ?>
<!-- Display Message -->
<div class="alert alert-danger" role="alert">
<?php echo $this->session->flashdata('error'); ?>
</div>
<?php } ?>
<?php if($this->session->flashdata('warning')) { ?>
<!-- Display Message -->
<div class="alert alert-warning" role="alert">
<?php echo $this->session->flashdata('warning'); ?>
</div>
<?php } ?>
@ -33,8 +47,6 @@
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label" for="width">Width of paper</label>
<div class="col-sm-4">

查看文件

@ -3,8 +3,22 @@
<br>
<?php if($this->session->flashdata('message')) { ?>
<!-- Display Message -->
<div class="alert-message error">
<p><?php echo $this->session->flashdata('message'); ?></p>
<div class="alert alert-success" role="alert">
<?php echo $this->session->flashdata('message'); ?>
</div>
<?php } ?>
<?php if($this->session->flashdata('error')) { ?>
<!-- Display Message -->
<div class="alert alert-danger" role="alert">
<?php echo $this->session->flashdata('error'); ?>
</div>
<?php } ?>
<?php if($this->session->flashdata('warning')) { ?>
<!-- Display Message -->
<div class="alert alert-warning" role="alert">
<?php echo $this->session->flashdata('warning'); ?>
</div>
<?php } ?>