Added color category to categories

This commit is contained in:
root 2019-05-07 00:24:11 -04:00
parent cf7003e7f1
commit 7565f8e86d
4 changed files with 15 additions and 2 deletions

View File

@ -22,6 +22,10 @@
<?php } ?>
</select>
</div>
<div class="form-group">
<label>Color</label>
<input type="color" class="form-control" name="color">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>

View File

@ -14,6 +14,7 @@
<tr>
<th>Name</th>
<th>Type</th>
<th>Color</th>
<th class="text-center">Actions</th>
</tr>
</thead>
@ -24,11 +25,13 @@
$category_id = $row['category_id'];
$category_name = $row['category_name'];
$category_type = $row['category_type'];
$category_color = $row['category_color'];
?>
<tr>
<td><?php echo "$category_name"; ?></td>
<td><?php echo "$category_type"; ?></td>
<td><i class="fa fa-2x fa-circle" style="color:<?php echo $category_color; ?>;"></i></td>
<td>
<div class="dropdown dropleft text-center">
<button class="btn btn-secondary btn-sm" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">

View File

@ -21,6 +21,10 @@
<?php } ?>
</select>
</div>
<div class="form-group">
<label>Color</label>
<input type="color" class="form-control" name="color" value="<?php echo $category_color; ?>">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>

View File

@ -501,8 +501,9 @@ if(isset($_POST['add_category'])){
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
$type = strip_tags(mysqli_real_escape_string($mysqli,$_POST['type']));
$color = strip_tags(mysqli_real_escape_string($mysqli,$_POST['color']));
mysqli_query($mysqli,"INSERT INTO categories SET category_name = '$name', category_type = '$type'");
mysqli_query($mysqli,"INSERT INTO categories SET category_name = '$name', category_type = '$type', category_color = '$color'");
$_SESSION['alert_message'] = "Category added";
@ -515,8 +516,9 @@ if(isset($_POST['edit_category'])){
$category_id = intval($_POST['category_id']);
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
$type = strip_tags(mysqli_real_escape_string($mysqli,$_POST['type']));
$color = strip_tags(mysqli_real_escape_string($mysqli,$_POST['color']));
mysqli_query($mysqli,"UPDATE categories SET category_name = '$name', category_type = '$type' WHERE category_id = $category_id");
mysqli_query($mysqli,"UPDATE categories SET category_name = '$name', category_type = '$type', category_color = '$color' WHERE category_id = $category_id");
$_SESSION['alert_message'] = "Category modified";