Skip to content

Commit

Permalink
Merge pull request #187 from globaldyne/v11.4
Browse files Browse the repository at this point in the history
V11.4
  • Loading branch information
globaldyne authored Sep 21, 2024
2 parents 0865eca + bfce482 commit 00adf5e
Show file tree
Hide file tree
Showing 19 changed files with 280 additions and 112 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# CHANGELOG
### Version 11.4
- Add shelf life for ingredients
- Add temprature measurement unit
- Add solubility options instead of a free text for ingredients
- Cleaner and better view for formula comparison
- Minor UI updates

### Version 11.3
- Minor UI updates
- Fix merge ingredient returning incorrect value when nothing found
Expand Down
2 changes: 1 addition & 1 deletion VERSION.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11.3
11.4
20 changes: 18 additions & 2 deletions css/vault.css
Original file line number Diff line number Diff line change
Expand Up @@ -832,10 +832,25 @@ body {
}

.pv_formula_diff {
color: #858796;
background-color: #f6c23e75 !important;
}

.pv_formula_nodiff {
background-color: #47aa5d !important;
}

.pv_formula_match {
background-color: #47aa5d !important;
}

.pv_formula_missing {
background-color: #bd8787 !important;
}

.pv_formula_added {
background-color: #a587bd !important;
}

#formula_name {
display: inline;
}
Expand Down Expand Up @@ -1335,9 +1350,10 @@ hr.hr-text::before {

.badge-success {
color: #fff;
background-color: #28a745;
background-color: #28a745 !important;
}


.badge-success[href]:hover, .badge-success[href]:focus {
color: #fff;
text-decoration: none;
Expand Down
6 changes: 4 additions & 2 deletions db/pvault.sql
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ CREATE TABLE `ingredients` (
`isPrivate` INT NULL DEFAULT '0',
`molecularWeight` VARCHAR(255) NULL,
`physical_state` INT NULL DEFAULT '1',
`cid` INT NULL,
`cid` INT NULL,
`shelf_life` INT NOT NULL DEFAULT '0'
`created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

Expand Down Expand Up @@ -329,7 +330,8 @@ CREATE TABLE `settings` (
`pv_scale_enabled` INT NOT NULL DEFAULT '0',
`pv_host` VARCHAR(255) NOT NULL DEFAULT 'localhost',
`sds_disclaimer` MEDIUMTEXT NOT NULL DEFAULT 'PLEASE ADD A PROPER DISCLAIMER MESSAGE',
`bs_theme` VARCHAR(255) NOT NULL DEFAULT 'light'
`bs_theme` VARCHAR(255) NOT NULL DEFAULT 'light',
`temp_sys` VARCHAR(255) NOT NULL DEFAULT '°C'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

INSERT INTO `settings` (`id`, `currency`, `top_n`, `heart_n`, `base_n`, `chem_vs_brand`, `grp_formula`, `brandName`, `brandAddress`, `brandEmail`, `brandPhone`, `brandLogo`) VALUES
Expand Down
2 changes: 1 addition & 1 deletion db/schema.ver
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11.3
11.4
2 changes: 2 additions & 0 deletions db/updates/update_11.3-11.4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE `settings` ADD `temp_sys` VARCHAR(255) NOT NULL DEFAULT '°C' AFTER `bs_theme`;
ALTER TABLE `ingredients` ADD `shelf_life` INT NOT NULL DEFAULT '0' AFTER `cid`;
8 changes: 5 additions & 3 deletions pages/compareFormulas.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<div class="card-body">
<?php
if(mysqli_num_rows(mysqli_query($conn, "SELECT id FROM formulasMetaData"))== 0){
echo '<div class="alert alert-info alert-dismissible"><strong>INFO: </strong> You need to <a href="/?do=listFormulas">create</a> at least one formula first.</div>';
echo '<div class="alert alert-info"><i class="fa-solid fa-triangle-exclamation mx-2"></i>You need to <a href="/?do=listFormulas">create</a> at least one formula first.</div>';
return;
}

if(mysqli_num_rows(mysqli_query($conn, "SELECT id FROM ingredients WHERE type = 'Carrier' OR type = 'Solvent'"))== 0){
echo '<div class="alert alert-info alert-dismissible"><strong>INFO: </strong> You need to <a href="/?do=ingredients">add</a> at least one solvent or carrier first.</div>';
echo '<div class="alert alert-info"><i class="fa-solid fa-triangle-exclamation mx-2"></i>You need to <a href="/?do=ingredients">add</a> at least one solvent or carrier first.</div>';
return;
}
?>
Expand Down Expand Up @@ -66,8 +66,10 @@
url: '/pages/views/formula/cmp_formulas_data.php',
type: 'POST',
data: {
id_a: $("#formula_a").val(),
id_a: $("#formula_a").val(),
name_a: $("#formula_a option:selected").text(),
id_b: $("#formula_b").val(),
name_b: $("#formula_b option:selected").text(),
},
dataType: 'html',
success: function (data) {
Expand Down
5 changes: 3 additions & 2 deletions pages/update_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -1665,11 +1665,12 @@ function formatVal($num){
$molecularWeight = mysqli_real_escape_string($conn, $_POST["molecularWeight"]);
$appearance = mysqli_real_escape_string($conn, $_POST["appearance"]);
$rdi = (int)$_POST["rdi"]?:0;
$shelf_life = mysqli_real_escape_string($conn, $_POST["shelf_life"]) ?: 0;


$query = "UPDATE ingredients SET tenacity='$tenacity',flash_point='$flash_point',chemical_name='$chemical_name',formula='$formula',logp = '$logp',soluble = '$soluble',molecularWeight = '$molecularWeight',appearance='$appearance',rdi='$rdi' WHERE id='$ingID'";
$query = "UPDATE ingredients SET tenacity='$tenacity',flash_point='$flash_point',chemical_name='$chemical_name',formula='$formula',logp = '$logp',soluble = '$soluble',molecularWeight = '$molecularWeight',appearance='$appearance',rdi='$rdi', shelf_life = '$shelf_life' WHERE id='$ingID'";
if(mysqli_query($conn, $query)){
$response["success"] = 'Technical data has been updated!';
$response["success"] = 'Technical data has been updated';
}else{
$response["error"] = 'Something went wrong '.mysqli_error($conn);
}
Expand Down
3 changes: 2 additions & 1 deletion pages/update_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
$user_pref_eng = mysqli_real_escape_string($conn, $_POST['user_pref_eng']);
$defPercentage = $_POST['defPercentage'];
$bs_theme = $_POST['bs_theme'];
$temp_sys = $_POST['temp_sys'];

if($_POST["chem_vs_brand"] == 'true') {
$chem_vs_brand = '1';
Expand Down Expand Up @@ -142,7 +143,7 @@
return;
}

if(mysqli_query($conn, "UPDATE settings SET currency = '$currency', currency_code = '$currency_code', top_n = '$top_n', heart_n = '$heart_n', base_n = '$base_n', chem_vs_brand = '$chem_vs_brand', grp_formula = '$grp_formula', pubChem='$pubChem', chkVersion='$chkVersion', qStep = '$qStep', defCatClass = '$defCatClass', pubchem_view = '$pubchem_view', multi_dim_perc = '$multi_dim_perc', mUnit = '$mUnit', editor = '$editor', user_pref_eng = '$user_pref_eng', pv_host = '".$_POST['pv_host']."', defPercentage = '$defPercentage', bs_theme = '$bs_theme'")){
if(mysqli_query($conn, "UPDATE settings SET currency = '$currency', currency_code = '$currency_code', top_n = '$top_n', heart_n = '$heart_n', base_n = '$base_n', chem_vs_brand = '$chem_vs_brand', grp_formula = '$grp_formula', pubChem='$pubChem', chkVersion='$chkVersion', qStep = '$qStep', defCatClass = '$defCatClass', pubchem_view = '$pubchem_view', multi_dim_perc = '$multi_dim_perc', mUnit = '$mUnit', editor = '$editor', user_pref_eng = '$user_pref_eng', pv_host = '".$_POST['pv_host']."', defPercentage = '$defPercentage', bs_theme = '$bs_theme', temp_sys = '$temp_sys' ")){
$response["success"] = 'Settings updated';
}else{
$response["error"] = 'An error occured '.mysqli_error($conn);
Expand Down
203 changes: 139 additions & 64 deletions pages/views/formula/cmp_formulas_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,71 +14,146 @@

$(document).ready(function() {
var formula_a_length;
var formula_a_name = '<?=$_POST['name_a']?>';
var formula_b_name = '<?=$_POST['name_b']?>';

var formula_a_table = $('#formula_a_table').DataTable( {
dom: 'lfrtip',
language: {
loadingRecords: '&nbsp;',
processing: '<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i><span class="sr-only">Loading...</span>',
emptyTable: "Incomplete formula.",
search: "Search in formula:",
},
ajax: {
url: '/core/full_formula_data.php?id=<?=$id_a?>'
},
columns: [
{ data : 'ingredient.name', title: 'Ingredient'},
{ data : 'purity', title: 'Purity %'},
{ data : 'quantity', title: 'Quantity'},
],
lengthMenu: [[50, 100, 200, -1], [50, 100, 200, "All"]],
pageLength: 100,
displayLength: 100,
});
var formula_a_table = $('#formula_a_table').DataTable({
dom: '<"top"f><"formula-name-a">rt<"bottom"lip><"clear">',
processing: true,
language: {
loadingRecords: '&nbsp;',
processing: '<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i><span class="sr-only">Loading...</span>',
emptyTable: "Incomplete formula.",
search: "",
searchPlaceholder: 'Search by name',
},
ajax: {
url: '/core/full_formula_data.php?id=<?=$id_a?>'
},
columns: [
{ data: 'ingredient.name', title: 'Ingredient' },
{ data: 'purity', title: 'Purity %' },
{ data: 'concentration', title: 'Concentration %' }
],
lengthMenu: [[50, 100, 200, -1], [50, 100, 200, "All"]],
pageLength: 100,
displayLength: 100,
});

formula_a_table.on('draw', function () {
formula_a_length = formula_a_table.rows().count();
});


var url = '/core/full_formula_data.php?id=<?=$id_b?>';
<?php if($_POST['revID']){ ?>
var url = '/core/full_revision_data.php?fid=<?=$_POST['fid']?>&revID=<?=$_POST['revID']?>';
<?php } ?>
var formula_b_table = $('#formula_b_table').DataTable({
dom: 'lfrtip',
language: {
loadingRecords: '&nbsp;',
processing: '<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i><span class="sr-only">Loading...</span>',
emptyTable: "Incomplete formula.",
search: "Search in formula:",
},
ajax: {
url: url
},
columns: [
{ data : 'ingredient.name', title: 'Ingredient'},
{ data : 'purity', title: 'Purity %'},
{ data : 'quantity', title: 'Quantity'},
],
lengthMenu: [[50, 100, 200, -1], [50, 100, 200, "All"]],
pageLength: 100,
displayLength: 100,
rowCallback: function (formula_b_tableRow, formula_b_tableData) {
for ( var y=0; y < formula_a_length; y++ ) {
var formula_a_data = formula_a_table.row(y).data();
if (formula_a_data.quantity === formula_b_tableData.quantity &&
formula_a_data.ingredient.name === formula_b_tableData.ingredient.name) {
$(formula_b_tableRow).removeClass().addClass('badge-success');
break;
}else{
$(formula_b_tableRow).removeClass().addClass('pv_formula_diff');
}
}
}
});
$('<div class="formula-name" style="float:left; font-weight:bold; margin-top:-35px;"><a href="/?do=Formula&id=<?=$id_a?>" target="_blank">' + formula_a_name + '<i class="fa-solid fa-arrow-up-right-from-square ml-2"></i></a></div>').appendTo('.formula-name-a');

formula_a_table.on('draw', function () {
formula_a_length = formula_a_table.rows().count();
});

var url = '/core/full_formula_data.php?id=<?=$id_b?>';
<?php if($_POST['revID']) { ?>
var url = '/core/full_revision_data.php?fid=<?=$_POST['fid']?>&revID=<?=$_POST['revID']?>';
<?php } ?>

var formula_b_table = $('#formula_b_table').DataTable({
dom: '<"top"f><"formula-name-b">rt<"bottom"lip><"clear">',
processing: true,
language: {
loadingRecords: '&nbsp;',
processing: '<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i><span class="sr-only">Loading...</span>',
emptyTable: "Incomplete formula.",
search: "",
searchPlaceholder: 'Search by name'
},
ajax: {
url: url
},
columns: [
{ data: 'ingredient.name', title: 'Ingredient' },
{ data: 'purity', title: 'Purity %' },
{ data: 'concentration', title: 'Concentration %' }
],
lengthMenu: [[50, 100, 200, -1], [50, 100, 200, "All"]],
pageLength: 100,
displayLength: 100,

rowCallback: function (formula_b_tableRow, formula_b_tableData) {
var isMatching = false;
var comparisonIcon = '';
var formula_a_data;

for (var y = 0; y < formula_a_length; y++) {
formula_a_data = formula_a_table.row(y).data();

if (formula_a_data.ingredient.name === formula_b_tableData.ingredient.name) {
isMatching = true;

if (parseFloat(formula_b_tableData.concentration) > parseFloat(formula_a_data.concentration)) {
comparisonIcon = '<i class="fa-solid fa-arrow-trend-up mx-2" rel="tip" title="Value has been increased"></i>';
} else if (parseFloat(formula_b_tableData.concentration) < parseFloat(formula_a_data.concentration)) {
comparisonIcon = '<i class="fa-solid fa-arrow-trend-down mx-2" rel="tip" title="Value has been decreased"></i>';
}else {
comparisonIcon = '<i class="fa-solid fa-check mx-2" rel="tip" title="Value matches"></i>';
//$(formula_b_tableRow).removeClass().addClass('pv_formula_nodiff');
$(formula_b_tableRow).addClass('pv_formula_nodiff');

$(formula_a_table.row(y).node()).addClass('pv_formula_nodiff');
$('td:eq(2)', formula_a_table.row(y).node()).html(formula_a_data.concentration + ' <i class="fa-solid fa-check mx-2" rel="tip" title="Value matches"></i>');
extrasShow();
}

$('td:eq(2)', formula_b_tableRow).html(formula_b_tableData.concentration + ' ' + comparisonIcon);
break;
}
}

if (!isMatching) {
$(formula_b_tableRow).removeClass().addClass('pv_formula_added');
var currentHtml = $('td:eq(2)', formula_b_tableRow).text();
$('td:eq(2)', formula_b_tableRow).html(currentHtml + ' <i class="fa-solid fa-circle-plus mx-2" rel="tip" title="Ingredient has been added"></i>');

} else {
if (comparisonIcon !== '' && comparisonIcon.indexOf('fa-check') === -1) {
$(formula_b_tableRow).removeClass().addClass('pv_formula_diff');
} else {
$(formula_b_tableRow).removeClass().addClass('pv_formula_nodiff');
}
}
}
});

$('<div class="formula-name" style="float:left; font-weight:bold; margin-top:-35px;"><a href="/?do=Formula&id=<?=$id_b?>" target="_blank">' + formula_b_name + '<i class="fa-solid fa-arrow-up-right-from-square ml-2"></i></a></div>').appendTo('.formula-name-b');

formula_b_table.on('draw', function () {
formula_b_length = formula_b_table.rows().count();

formula_a_table.rows().every(function () {
var formula_a_data = this.data();
var isFoundInB = false;

for (var x = 0; x < formula_b_length; x++) {
var formula_b_data = formula_b_table.row(x).data();

if (formula_a_data.ingredient.name === formula_b_data.ingredient.name) {
isFoundInB = true;
break;
}
}

if (!isFoundInB) {
$(this.node()).addClass('pv_formula_missing');
var currentHtml = $('td:eq(2)', this.node()).text();
$('td:eq(2)', this.node()).html(currentHtml + ' <i class="fa-solid fa-circle-minus mx-2" rel="tip" title="Ingredient has been removed"></i>');
extrasShow();

}
});
});

function extrasShow() {
$('[rel=tip]').tooltip({
"html": true,
"delay": {"show": 100, "hide": 0},
});
};

});//doc ready
});


</script>
Expand All @@ -89,7 +164,7 @@
<tr>
<th>Ingredient</th>
<th>Purity %</th>
<th>Quantity</th>
<th>Concentration %</th>
</tr>
</thead>
</table>
Expand All @@ -100,7 +175,7 @@
<tr>
<th>Ingredient</th>
<th>Purity %</th>
<th>Quantity</th>
<th>Concentration %</th>
</tr>
</thead>
</table>
Expand Down
4 changes: 3 additions & 1 deletion pages/views/ingredients/compos.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@
order: [[ 1, 'asc' ]],
lengthMenu: [[20, 50, 100, -1], [20, 50, 100, "All"]],
pageLength: 20,
displayLength: 20,
displayLength: 20,
scrollCollapse: true,
scrollY: '500px'
});

$('#allgName').on('input', function(){
Expand Down
4 changes: 3 additions & 1 deletion pages/views/ingredients/ingDocuments.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@
order: [[ 1, 'asc' ]],
lengthMenu: [[20, 50, 100, -1], [20, 50, 100, "All"]],
pageLength: 20,
displayLength: 20,
displayLength: 20,
scrollCollapse: true,
scrollY: '500px'
});

function dName(data, type, row){
Expand Down
3 changes: 2 additions & 1 deletion pages/views/ingredients/ingSuppliers.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@
lengthMenu: [[20, 50, 100, -1], [20, 50, 100, "All"]],
pageLength: 20,
displayLength: 20,

scrollCollapse: true,
scrollY: '500px',
stateSave: true,
stateDuration : -1,
stateLoadCallback: function (settings, callback) {
Expand Down
Loading

0 comments on commit 00adf5e

Please sign in to comment.