Skip to content

Commit

Permalink
Merge pull request #192 from globaldyne/v11.7
Browse files Browse the repository at this point in the history
V11.7
  • Loading branch information
globaldyne authored Oct 20, 2024
2 parents 2713856 + a47e6e0 commit 77b5d2d
Show file tree
Hide file tree
Showing 24 changed files with 755 additions and 545 deletions.
13 changes: 9 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# CHANGELOG
### Version 11.6
- Fix a bug incorrectly marking materials as banned in a formula
- Fix a typo in db schema creation for new installations
- Minor updates in sys-upgrade
### Version 11.7
- Formulation: Make sure dilutant is disabled if material is at 100%
- Formulation: Auto remove/add decimal point in quantity depending user's input
- Formulation: Added formula obscure when in a locked state
- Settings: Show/hide api key
- Formula settings page minor updates
- Add IFRA Categories explanation in usage page
- Make sure empty formula returns array for meta data
- Set scroll collapse for datatbales in ingredients to false

### Version 11.5
- Fix revisions comparison
Expand Down
2 changes: 1 addition & 1 deletion VERSION.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11.6
11.7
7 changes: 4 additions & 3 deletions core/finished_formula_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@

}

if(empty($r)){
$response['data'] = [];
}
$carrier_sub_cost = number_format($carrier_cost['price'] / $carrier_cost['size'] * $carrier, $settings['qStep']);

$m['sub_total_quantity'] = number_format(array_sum($new_tot), $settings['qStep']);
Expand Down Expand Up @@ -224,6 +221,10 @@
$response['meta'] = $m;


if(empty($r)){
$response['meta'] = [];
$response['data'] = [];
}
header('Content-Type: application/json; charset=utf-8');
echo json_encode($response);
return;
Expand Down
1 change: 1 addition & 0 deletions core/full_formula_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@

if(empty($r)){
$response['data'] = [];
$response['meta'] = [];
echo json_encode($response);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion core/list_frmCat_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
$response['data'][] = $r;
}

if(empty($r)){
if(empty($c)){
$response['data'] = [];
}

Expand Down
34 changes: 34 additions & 0 deletions core/list_ifra_cat_data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
define('__ROOT__', dirname(dirname(__FILE__)));

require_once(__ROOT__.'/inc/sec.php');
require_once(__ROOT__.'/inc/opendb.php');


$data = [];

$q = mysqli_query($conn, "SELECT id, name, description FROM IFRACategories");
while ($category = mysqli_fetch_assoc($q)){
$c = [
'id' => (int)$category['id'],
'name' => (string)$category['name'],
'description' => (string)$category['description']
];
$data[] = $c;
}

$total = mysqli_fetch_assoc(mysqli_query($conn,"SELECT COUNT(id) AS entries FROM IFRACategories"));

$response = array(
"draw" => (int)$_POST['draw'],
"recordsTotal" => (int)$total['entries'],
"recordsFiltered" => (int)$total['entries'],
"data" => $data
);

header('Content-Type: application/json; charset=utf-8');
echo json_encode($response);
return;


?>
12 changes: 12 additions & 0 deletions css/vault.css
Original file line number Diff line number Diff line change
Expand Up @@ -1521,3 +1521,15 @@ th.dt-center, td.dt-center {
border-radius: var(--bs-border-radius);
transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}

.div-obs{
filter: blur(3px);
}

.concentration-details {
display: inline-block;
}

.final-concentration-details {
display: inline-block;
}
2 changes: 1 addition & 1 deletion db/schema.ver
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11.6
11.7
9 changes: 7 additions & 2 deletions func/convert_to_decimal_point.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<?php
if (!defined('pvault_panel')){ die('Not Found');}

function convert_to_decimal_point($number) {
function convert_to_decimal_point($number, $decimal = TRUE) {
$decimalPlaces = (int)$number;

if ($decimalPlaces > 0) {
return '.' . str_repeat('0', $decimalPlaces);
if($decimal){

return '.' . str_repeat('0', $decimalPlaces);
}else {
return str_repeat('0', $decimalPlaces);
}
} else {
return '0'; // If 0 or negative, return plain 0
}
Expand Down
4 changes: 2 additions & 2 deletions js/select2-v3-ingredient.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ $(document).ready(function(){
$("#dilutant").prop("disabled", true).val('none').selectpicker("refresh");
} else {
$("#concentration").prop("disabled", false).val(data.purity).trigger("input");
$("#dilutant").prop("disabled", false).val(data.solvent).selectpicker("refresh");
//$("#dilutant").prop("disabled", false).val(data.solvent).selectpicker("refresh");
}

$("#quantity").prop("disabled", false);
Expand All @@ -211,7 +211,7 @@ $(document).ready(function(){
});
});

$('#concentration').on('input', function() {
$('#concentration').on('input change', function() {
const MAX_CONCENTRATION = 100;
var concentration = parseFloat($(this).val());

Expand Down
5 changes: 3 additions & 2 deletions pages/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@

<strong><i class="fa-solid fa-heart mx-2"></i><a href="https://www.paypal.com/paypalme/jbparfum" target="_blank" class="pv_point_gen">Donate if you found this useful.
</a></strong>
<hr>
<hr/>
<strong><a href="https://www.perfumersvault.com" target="_blank"><?php echo $product; ?></a></strong>
<div id="footer_release" class="pv_point_gen"> Version: <strong><?php echo $ver ." - ". $commit; ?> | <a href="https://discord.gg/WxNE8kR8ug" target="_blank">Discord Server</a></strong></div>
<div id="footer_release" class="pv_point_gen"> Version: <strong><?php echo $ver ." - ". $commit; ?></strong></div>
<div><a href="https://discord.gg/WxNE8kR8ug" target="_blank"><strong>Discord Server</strong></a></div>
<div class="mt-2">Copyright &copy; 2017-<?php echo date('Y'); ?></div>
</div>
</div>
Expand Down
54 changes: 37 additions & 17 deletions pages/formula.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
if($form[0]['ingredient']){
$legend = 1;
}
require_once(__ROOT__.'/func/convert_to_decimal_point.php');
//require_once(__ROOT__.'/func/convert_to_decimal_point.php');

?>

Expand Down Expand Up @@ -158,7 +158,7 @@
<div class="col-md-2">
<div class="input-group">
<input type="text" name="quantity" id="quantity" placeholder="Quantity" class="form-control" aria-label="quantity" aria-describedby="quantity-addon">
<span class="input-group-text" id="quantity-addon"><?= convert_to_decimal_point($settings['qStep']).$settings['mUnit'] ?></span>
<span class="input-group-text" id="quantity-addon"></span>
</div>
</div>

Expand Down Expand Up @@ -281,19 +281,42 @@

<script src="/js/select2-v3-ingredient.js"></script>
<script>
document.title = "<?=$meta['name'].' - '.$product?>";
var myFID = "<?=$fid?>";
var isProtected = "<?=$meta['isProtected']?>";
$(document).ready(function() {

$('#formula_name').click(function() {
reload_formula_data();
});

$('#add_ing').hide();

if(isProtected == '0'){
$('#add_ing').show();
}
function convertToDecimalPoint(qStep, hasDot) {
let zeros = '0'.repeat(qStep);
return hasDot ? zeros : '.' + zeros;
}

const settings = {
qStep: <?=$settings['qStep']?>,
mUnit: '<?=$settings['mUnit']?>'
};

function updateSpan() {
let quantityInput = document.getElementById('quantity').value;
let hasDot = quantityInput.includes('.');
let decimalPart = convertToDecimalPoint(settings.qStep, hasDot);
document.getElementById('quantity-addon').textContent = decimalPart + settings.mUnit;
}

document.getElementById('quantity').addEventListener('input', updateSpan);
document.getElementById('quantity-addon').textContent = convertToDecimalPoint(settings.qStep, false) + settings.mUnit;

document.title = "<?=$meta['name'].' - '.$product?>";
var myFID = "<?=$fid?>";
var isProtected = "<?=$meta['isProtected']?>";

$('#formula_name').click(function() {
reload_formula_data();
});

$('#add_ing').hide();

if(isProtected == '0'){
$('#add_ing').show();
}
});//END DOC - TODO

$("#concentration").prop("disabled", true);
$("#dilutant").prop("disabled", true);
Expand Down Expand Up @@ -478,9 +501,6 @@ function fetch_summary(){
});
};




function fetch_replacements(){
$.ajax({
url: '/pages/views/formula/replacements.php',
Expand Down
6 changes: 3 additions & 3 deletions pages/makeFormula.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@
<li class="dropdown-header">Options</li>
<li><a class="dropdown-item" href="#" id="toggleAdded"><i class="bi bi-list-check mx-2"></i>Show/hide added</a></li>

<div class="dropdown-divider"></div>
<li class="dropdown-header">Export</li>
<div class="dropdown-divider"></div>
<li class="dropdown-header">Export</li>
<li><a class="dropdown-item" href="/pages/operations.php?action=exportMaking&fid=<?=$fid?>"><i class="fa-solid fa-file-code mx-2"></i>Export as JSON</a></li>
<li><a class="dropdown-item export_as" href="#" data-format="csv"><i class="fa-solid fa-file-csv mx-2"></i>Export as CSV</a></li>
<li><a class="dropdown-item export_as" href="#" data-format="pdf"><i class="fa-solid fa-file-code mx-2"></i>Export as PDF</a></li>
<li><a class="dropdown-item" href="#" id="print"><i class="fa-solid fa-print mx-2"></i>Print Formula</a></li>
<li><a class="dropdown-item" href="#" id="print"><i class="fa-solid fa-print mx-2"></i>Print formula</a></li>
</div>
</div>
<table class="table table-striped" id="tdDataPending" width="100%" cellspacing="0">
Expand Down
4 changes: 2 additions & 2 deletions pages/views/formula/finishedProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@
paging: false,
language: {
loadingRecords: '&nbsp;',
processing: '<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i><span class="sr-only">Blending...</span>',
emptyTable: '<div class="alert alert-warning"><strong>Empty formula</strong></div>',
//processing: '<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i>',
emptyTable: '<div class="alert alert-warning"><strong><i class="fa-solid fa-circle-info mx-2"></i>Empty or invalid formula</strong></div>',
},
//dom: 'B',
buttons: [
Expand Down
Loading

0 comments on commit 77b5d2d

Please sign in to comment.