mirror of https://github.com/itflow-org/itflow
Changed product cost to product price as it makes more sense, some cleanup on the new product auto complete feature, added JQueryUI as a local asset instead of a remote asset
This commit is contained in:
parent
07223dc2c2
commit
0d306e961e
|
|
@ -47,8 +47,8 @@
|
|||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Cost <strong class="text-danger">*</strong></label>
|
||||
<input type="number" step="0.01" min="0" class="form-control" name="cost" placeholder="Cost" required>
|
||||
<label>Price <strong class="text-danger">*</strong></label>
|
||||
<input type="number" step="0.01" min="0" class="form-control" name="price" placeholder="Price" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
|
|
|||
4
db.sql
4
db.sql
|
|
@ -722,7 +722,7 @@ CREATE TABLE `products` (
|
|||
`product_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`product_name` varchar(200) NOT NULL,
|
||||
`product_description` text DEFAULT NULL,
|
||||
`product_cost` decimal(15,2) NOT NULL,
|
||||
`product_price` decimal(15,2) NOT NULL,
|
||||
`product_currency_code` varchar(200) NOT NULL,
|
||||
`product_created_at` datetime NOT NULL,
|
||||
`product_updated_at` datetime DEFAULT NULL,
|
||||
|
|
@ -1217,4 +1217,4 @@ CREATE TABLE `vendors` (
|
|||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2022-01-12 19:48:54
|
||||
-- Dump completed on 2022-01-16 15:27:33
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@
|
|||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Cost <strong class="text-danger">*</strong></label>
|
||||
<input type="number" step="0.01" min="0" class="form-control" name="cost" value="<?php echo $product_cost; ?>" required>
|
||||
<label>Price <strong class="text-danger">*</strong></label>
|
||||
<input type="number" step="0.01" min="0" class="form-control" name="price" value="<?php echo $product_price; ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
JQuery UI 1.13.0
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
8
post.php
8
post.php
|
|
@ -1787,11 +1787,11 @@ if(isset($_POST['add_product'])){
|
|||
|
||||
$name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])));
|
||||
$description = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['description'])));
|
||||
$cost = floatval($_POST['cost']);
|
||||
$price = floatval($_POST['price']);
|
||||
$category = intval($_POST['category']);
|
||||
$tax = intval($_POST['tax']);
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO products SET product_name = '$name', product_description = '$description', product_cost = '$cost', product_currency_code = '$session_company_currency', product_created_at = NOW(), product_tax_id = $tax, product_category_id = $category, company_id = $session_company_id");
|
||||
mysqli_query($mysqli,"INSERT INTO products SET product_name = '$name', product_description = '$description', product_price = '$price', product_currency_code = '$session_company_currency', product_created_at = NOW(), product_tax_id = $tax, product_category_id = $category, company_id = $session_company_id");
|
||||
|
||||
//logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Product', log_action = 'Create', log_description = '$session_name created product $name', log_created_at = NOW(), company_id = $session_company_id, log_user_id = $session_user_id");
|
||||
|
|
@ -1807,11 +1807,11 @@ if(isset($_POST['edit_product'])){
|
|||
$product_id = intval($_POST['product_id']);
|
||||
$name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])));
|
||||
$description = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['description'])));
|
||||
$cost = floatval($_POST['cost']);
|
||||
$price = floatval($_POST['price']);
|
||||
$category = intval($_POST['category']);
|
||||
$tax = intval($_POST['tax']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE products SET product_name = '$name', product_description = '$description', product_cost = '$cost', product_updated_at = NOW(), product_tax_id = $tax, product_category_id = $category WHERE product_id = $product_id AND company_id = $session_company_id");
|
||||
mysqli_query($mysqli,"UPDATE products SET product_name = '$name', product_description = '$description', product_price = '$price', product_updated_at = NOW(), product_tax_id = $tax, product_category_id = $category WHERE product_id = $product_id AND company_id = $session_company_id");
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Product', log_action = 'Modified', log_description = '$name', log_created_at = NOW(), company_id = $session_company_id, log_user_id = $session_user_id");
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ $url_query_strings_sb = http_build_query(array_merge($_GET,array('sb' => $sb, 'o
|
|||
|
||||
$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM products LEFT JOIN categories ON product_category_id = category_id
|
||||
WHERE products.company_id = $session_company_id
|
||||
AND (product_name LIKE '%$q%' OR product_description LIKE '%$q%' OR category_name LIKE '%$q%' OR product_cost LIKE '%$q%')
|
||||
AND (product_name LIKE '%$q%' OR product_description LIKE '%$q%' OR category_name LIKE '%$q%' OR product_price LIKE '%$q%')
|
||||
ORDER BY $sb $o LIMIT $record_from, $record_to");
|
||||
|
||||
$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
||||
|
|
@ -77,7 +77,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=product_name&o=<?php echo $disp; ?>">Name</a></th>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=category_name&o=<?php echo $disp; ?>">Category</a></th>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=product_description&o=<?php echo $disp; ?>">Description</a></th>
|
||||
<th class="text-right"><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=product_cost&o=<?php echo $disp; ?>">Cost</a></th>
|
||||
<th class="text-right"><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=product_price&o=<?php echo $disp; ?>">Price</a></th>
|
||||
<th class="text-center">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
@ -93,7 +93,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||
}else{
|
||||
$product_description_display = $product_description;
|
||||
}
|
||||
$product_cost = $row['product_cost'];
|
||||
$product_price = $row['product_price'];
|
||||
$product_created_at = $row['product_created_at'];
|
||||
$category_id = $row['category_id'];
|
||||
$category_name = $row['category_name'];
|
||||
|
|
@ -104,7 +104,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||
<td><a class="text-dark" href="#" data-toggle="modal" data-target="#editProductModal<?php echo $product_id; ?>"><?php echo $product_name; ?></a></td>
|
||||
<td><?php echo $category_name; ?></td>
|
||||
<td><?php echo $product_description_display; ?></td>
|
||||
<td class="text-right"><?php echo get_currency_symbol($session_company_currency); ?> <?php echo number_format($product_cost,2); ?></td>
|
||||
<td class="text-right"><?php echo get_currency_symbol($session_company_currency); ?> <?php echo number_format($product_price,2); ?></td>
|
||||
<td>
|
||||
<div class="dropdown dropleft text-center">
|
||||
<button class="btn btn-secondary btn-sm" type="button" data-toggle="dropdown">
|
||||
|
|
|
|||
53
quote.php
53
quote.php
|
|
@ -76,17 +76,16 @@ if(isset($_GET['quote_id'])){
|
|||
$quote_badge_color = "secondary";
|
||||
}
|
||||
|
||||
//Product autocomplete
|
||||
$products_sql = mysqli_query($mysqli,"SELECT product_name AS label, product_description AS description, product_price AS price FROM products WHERE company_id = $session_company_id");
|
||||
|
||||
// Product autocomplete
|
||||
$product_sql = mysqli_query($mysqli,"SELECT product_name AS label, product_description AS description, product_cost AS price FROM products
|
||||
WHERE products.company_id = $session_company_id");
|
||||
|
||||
if(mysqli_num_rows($product_sql) > 0){
|
||||
while($row = mysqli_fetch_array($product_sql)) {
|
||||
$products[] = $row;
|
||||
if(mysqli_num_rows($products_sql) > 0){
|
||||
while($row = mysqli_fetch_array($products_sql)){
|
||||
$products[] = $row;
|
||||
}
|
||||
$json_products = (json_encode($products));
|
||||
}
|
||||
$json_products = json_encode($products);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<ol class="breadcrumb d-print-none">
|
||||
|
|
@ -248,7 +247,7 @@ if(mysqli_num_rows($product_sql) > 0){
|
|||
<td class="text-center"><?php echo $item_quantity; ?></td>
|
||||
<td class="text-right"><?php echo $client_currency_symbol; ?> <?php echo number_format($item_price,2); ?></td>
|
||||
<td class="text-right"><?php echo $client_currency_symbol; ?> <?php echo number_format($item_tax,2); ?></td>
|
||||
<td class="text-right"><?php echo $client_currency_symbol; ?> <?php echo number_format($item_total,2); ?></td>
|
||||
<td class="text-right"><?php echo $client_currency_symbol; ?><?php echo number_format($item_total,2); ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
|
@ -265,10 +264,10 @@ if(mysqli_num_rows($product_sql) > 0){
|
|||
<td></td>
|
||||
<td><input type="text" class="form-control" name="name" id="name" placeholder="Item" required></td>
|
||||
<td><textarea class="form-control" rows="2" name="description" id="desc" placeholder="Description"></textarea></td>
|
||||
<td><input type="number" step="0.01" min="0" class="form-control" style="text-align: center;" name="qty" placeholder="QTY"></td>
|
||||
<td><input type="number" step="0.01" min="0" class="form-control" id="qty" style="text-align: center;" name="qty" placeholder="QTY"></td>
|
||||
<td><input type="number" step="0.01" min="0" class="form-control" id="price" style="text-align: right;" name="price" placeholder="Price (<?php echo $client_currency_symbol; ?>)"></td>
|
||||
<td>
|
||||
<select class="form-control select2" name="tax_id" required>
|
||||
<select class="form-control select2" id="tax" name="tax_id" required>
|
||||
<option value="0">None</option>
|
||||
<?php
|
||||
|
||||
|
|
@ -407,23 +406,23 @@ include("footer.php");
|
|||
|
||||
<!-- JSON Autocomplete / type ahead -->
|
||||
<!-- //TODO: Not sure quite how to make this more modular to include elsewhere, I'll leave that design decision down to you.. -->
|
||||
<link rel="stylesheet" href="https://code.jquery.com/ui/1.13.0/themes/base/jquery-ui.css">
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
|
||||
<script src="https://code.jquery.com/ui/1.13.0/jquery-ui.js"></script>
|
||||
<link rel="stylesheet" href="plugins/jquery-ui/jquery-ui.min.css">
|
||||
<script src="plugins/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script>
|
||||
$( function() {
|
||||
var availableProducts = <?php echo $json_products?>;
|
||||
$(function(){
|
||||
var availableProducts = <?php echo $json_products?>;
|
||||
|
||||
$("#name").autocomplete({
|
||||
source: availableProducts,
|
||||
select: function (event, ui){
|
||||
$("#name").val(ui.item.label); // Product name field - this seemingly has to referenced as label
|
||||
$("#desc").val(ui.item.description); // Product description field
|
||||
$("#price").val(ui.item.price); // Product price field
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} );
|
||||
$("#name").autocomplete({
|
||||
source: availableProducts,
|
||||
select: function (event, ui){
|
||||
$("#name").val(ui.item.label); // Product name field - this seemingly has to referenced as label
|
||||
$("#desc").val(ui.item.description); // Product description field
|
||||
$("#qty").val(1); // Product quantity field automatically make it a 1
|
||||
$("#price").val(ui.item.price); // Product price field
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script src='plugins/pdfmake/pdfmake.js'></script>
|
||||
|
|
|
|||
|
|
@ -181,7 +181,6 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||
$quote_created_at = $row['quote_created_at'];
|
||||
$client_id = $row['client_id'];
|
||||
$client_name = htmlentities($row['client_name']);
|
||||
//$client_email = $row['client_email']; - Commented Jan 2022 - clients database does not include email column
|
||||
$client_currency_code = $row['client_currency_code'];
|
||||
$category_id = $row['category_id'];
|
||||
$category_name = $row['category_name'];
|
||||
|
|
|
|||
Loading…
Reference in New Issue