Update Categories Create and Edit Modals to take advantage of custom colors
This commit is contained in:
+2
-21
@@ -31,21 +31,6 @@ if (isset($_GET['archived'])) {
|
|||||||
$category = "Archived";
|
$category = "Archived";
|
||||||
}
|
}
|
||||||
|
|
||||||
$colors_used_array = [];
|
|
||||||
|
|
||||||
//Colors Used
|
|
||||||
$sql_colors_used = mysqli_query(
|
|
||||||
$mysqli,
|
|
||||||
"SELECT category_color FROM categories
|
|
||||||
WHERE category_type = '$category'
|
|
||||||
AND category_$archive_query"
|
|
||||||
);
|
|
||||||
|
|
||||||
while ($color_used_row = mysqli_fetch_array($sql_colors_used)) {
|
|
||||||
$colors_used_array[] = $color_used_row['category_color'];
|
|
||||||
}
|
|
||||||
$colors_diff = array_diff($colors_array, $colors_used_array);
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
@@ -59,7 +44,7 @@ $colors_diff = array_diff($colors_array, $colors_used_array);
|
|||||||
?>
|
?>
|
||||||
<div class="card-tools">
|
<div class="card-tools">
|
||||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addCategoryModal"><i
|
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addCategoryModal"><i
|
||||||
class="fas fa-plus mr-2"></i>Create</button>
|
class="fas fa-plus mr-2"></i>New <?php echo nullable_htmlentities($category); ?> Category</button>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
@@ -75,7 +60,7 @@ $colors_diff = array_diff($colors_array, $colors_used_array);
|
|||||||
value="<?php if (isset($q)) {
|
value="<?php if (isset($q)) {
|
||||||
echo stripslashes(nullable_htmlentities($q));
|
echo stripslashes(nullable_htmlentities($q));
|
||||||
} ?>"
|
} ?>"
|
||||||
placeholder="Search Categories">
|
placeholder="Search <?php echo nullable_htmlentities($category); ?> Categories ">
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<button class="btn btn-primary"><i class="fa fa-search"></i></button>
|
<button class="btn btn-primary"><i class="fa fa-search"></i></button>
|
||||||
</div>
|
</div>
|
||||||
@@ -140,7 +125,6 @@ $colors_diff = array_diff($colors_array, $colors_used_array);
|
|||||||
$category_id = intval($row['category_id']);
|
$category_id = intval($row['category_id']);
|
||||||
$category_name = nullable_htmlentities($row['category_name']);
|
$category_name = nullable_htmlentities($row['category_name']);
|
||||||
$category_color = nullable_htmlentities($row['category_color']);
|
$category_color = nullable_htmlentities($row['category_color']);
|
||||||
//$colors_used_array[] = $row['category_color'];
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -187,11 +171,8 @@ $colors_diff = array_diff($colors_array, $colors_used_array);
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
//$colors_diff = array_diff($colors_array,$colors_used_array);
|
|
||||||
|
|
||||||
include "category_edit_modal.php";
|
include "category_edit_modal.php";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
+13
-17
@@ -14,26 +14,22 @@
|
|||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Name <strong class="text-danger">*</strong></label>
|
<label>Name <strong class="text-danger">*</strong></label>
|
||||||
<input type="text" class="form-control" name="name" placeholder="Category name" required autofocus>
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-list-ul"></i></span>
|
||||||
|
</div>
|
||||||
|
<input type="text" class="form-control" name="name" placeholder="Category name" required autofocus>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label>Color <strong class="text-danger">*</strong></label>
|
<div class="form-group">
|
||||||
<div class="form-row">
|
<label>Color <strong class="text-danger">*</strong></label>
|
||||||
|
<div class="input-group">
|
||||||
<?php
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-paint-brush"></i></span>
|
||||||
foreach ($colors_diff as $color) { ?>
|
|
||||||
|
|
||||||
<div class="col-3 mb-3">
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="radio" name="color" value="<?php echo $color; ?>">
|
|
||||||
<label class="form-check-label">
|
|
||||||
<i class="fa fa-fw fa-3x fa-circle" style="color:<?php echo $color; ?>"></i>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<input type="color" class="form-control col-3" name="color" required>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+12
-23
@@ -14,33 +14,22 @@
|
|||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Name <strong class="text-danger">*</strong></label>
|
<label>Name <strong class="text-danger">*</strong></label>
|
||||||
<input type="text" class="form-control" name="name" value="<?php echo $category_name; ?>" required>
|
<div class="input-group">
|
||||||
</div>
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-list-ul"></i></span>
|
||||||
<label>Color <strong class="text-danger">*</strong></label>
|
</div>
|
||||||
<div class="mb-3">
|
<input type="text" class="form-control" name="name" value="<?php echo $category_name; ?>" required>
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="radio" name="color" value="<?php echo $category_color; ?>" checked>
|
|
||||||
<label class="form-check-label">
|
|
||||||
<i class="fa fa-fw fa-4x fa-circle" style="color:<?php echo $category_color; ?>"></i>
|
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
|
||||||
|
|
||||||
<?php
|
<div class="form-group">
|
||||||
|
<label>Color <strong class="text-danger">*</strong></label>
|
||||||
foreach($colors_diff as $color) { ?>
|
<div class="input-group">
|
||||||
<div class="col-3 mb-3">
|
<div class="input-group-prepend">
|
||||||
<div class="form-check">
|
<span class="input-group-text"><i class="fa fa-fw fa-paint-brush"></i></span>
|
||||||
<input class="form-check-input" type="radio" name="color" value="<?php echo $color; ?>">
|
|
||||||
<label class="form-check-label">
|
|
||||||
<i class="fa fa-fw fa-3x fa-circle" style="color:<?php echo $color; ?>"></i>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<input type="color" class="form-control col-3" name="color" value="<?php echo $category_color; ?>" required>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
$name = sanitizeInput($_POST['name']);
|
$name = sanitizeInput($_POST['name']);
|
||||||
$type = sanitizeInput($_POST['type']);
|
$type = sanitizeInput($_POST['type']);
|
||||||
$color = preg_replace("/[^0-9a-zA-Z-]/", "", sanitizeInput($_POST['color']));
|
$color = sanitizeInput($_POST['color']);
|
||||||
|
|||||||
Reference in New Issue
Block a user