Skip to content

Commit

Permalink
Merge pull request #170 from globaldyne/v10.2
Browse files Browse the repository at this point in the history
V10.2
  • Loading branch information
globaldyne authored May 25, 2024
2 parents 3d7b656 + 3c93ace commit 723dd94
Show file tree
Hide file tree
Showing 29 changed files with 427 additions and 268 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
# CHANGELOG
### Version 10.2
- Minor improvements in finished product page
- Auto populate CAS and EC if entry exists as an ingredient when adding components in ingredient composition
- Extend simple search for ingredients to EC numbers
- Highlight corresponded ingredient that matches a compound name or CAS number in a formula
- Added GHS Classification for ingredient compounds
- Fix suppliers and compounds count when exporting ingredients to JSON
- Replace table with div for compositions page
- Update perfume types and httml templates page layout
- Make sure the modal box toggles when trying to schedule a formula which is already scheduled
- Fix user menu position
- Added JSON export for formula making
- Table allergens has been renamed to ingredient_compounds

### Version 10.1
- Added export to JSON for perfume types
- Added export to JSON for categories
Expand All @@ -10,6 +24,7 @@
- Allow ordering in formula sell table
- Set custom decimal precission when generating a formula to sell
- Fix export functions in Formula Make page

### Version 10.0
- Discord server link added
- Added archive option when deleting a formula
Expand Down
2 changes: 1 addition & 1 deletion VERSION.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.1
10.2
4 changes: 2 additions & 2 deletions core/full_formula_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
$replacement[] = $replacements;
}

$totalcontainsOthers = mysqli_num_rows(mysqli_query($conn, "SELECT name,percentage,cas FROM allergens WHERE ing = '".$formula['ingredient']."'"));
$totalcontainsOthers = mysqli_num_rows(mysqli_query($conn, "SELECT name,percentage,cas FROM ingredient_compounds WHERE ing = '".$formula['ingredient']."'"));


$inventory = mysqli_fetch_array(mysqli_query($conn, "SELECT stock,mUnit,batch,purchased FROM suppliers WHERE ingID = '".$ing_q['id']."' AND preferred = '1'"));
Expand All @@ -134,7 +134,7 @@
$conc_final = $formula['concentration'] / 100 * $formula['quantity']/$mg['total_mg'] * $meta['finalType'];

if($settings['multi_dim_perc'] == '1'){
$compos = mysqli_query($conn, "SELECT name,percentage,cas FROM allergens WHERE ing = '".$formula['ingredient']."'");
$compos = mysqli_query($conn, "SELECT name,percentage,cas FROM ingredient_compounds WHERE ing = '".$formula['ingredient']."'");

while($compo = mysqli_fetch_array($compos)){
$cmp[] = $compo;
Expand Down
3 changes: 2 additions & 1 deletion core/list_ing_compos_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

$ingID = base64_decode($_GET["id"]);

$q = mysqli_query($conn, "SELECT id,ing,name,cas,ec,percentage,toDeclare FROM allergens WHERE ing = '$ingID'");
$q = mysqli_query($conn, "SELECT id,ing,name,cas,ec,percentage,GHS,toDeclare FROM ingredient_compounds WHERE ing = '$ingID'");
while($res = mysqli_fetch_array($q)){
$compos[] = $res;
}
Expand All @@ -17,6 +17,7 @@
$r['name'] = (string)$compo['name'];
$r['cas'] = (string)$compo['cas']?: 'N/A';
$r['ec'] = (string)$compo['ec']?: 'N/A';
$r['GHS'] = (string)$compo['GHS']?: '-';
$r['percentage'] = (float)$compo['percentage']?: '0';
$r['toDeclare'] = (int)$compo['toDeclare']?: '0';

Expand Down
7 changes: 6 additions & 1 deletion core/list_ingredients_simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@
$t = "synonyms,ingredients";
$filter = "WHERE synonym LIKE '%$s%' AND ing = name GROUP BY name";

} else if($_POST['isAbsolute'] == "true"){
$t = "ingredients";
$filter = "WHERE name = '$s' OR cas = '$s' OR einecs = '$s' OR INCI = '$s'";

}else{
$t = "ingredients";
$filter = "WHERE name LIKE '%$s%' OR cas LIKE '%$s%' OR INCI LIKE '%$s%'";
}

$q = mysqli_query($conn, "SELECT ingredients.id,name,INCI,cas,type,odor,physical_state,profile FROM $t $filter ORDER BY name ASC");
$q = mysqli_query($conn, "SELECT ingredients.id,name,INCI,cas,einecs,type,odor,physical_state,profile FROM $t $filter ORDER BY name ASC");
while($res = mysqli_fetch_array($q)){
$ingredients[] = $res;
}
Expand All @@ -36,6 +40,7 @@
$r['name'] = (string)$ingredient['name'];
$r['IUPAC'] = (string)$ingredient['INCI']?: 'N/A';
$r['cas'] = (string)$ingredient['cas']?: 'N/A';
$r['einecs'] = (string)$ingredient['einecs']?: 'N/A';
$r['type'] = (string)$ingredient['type'] ?: 'Unknown';
$r['description'] = (string)$ingredient['odor'] ?: 'N/A';
$r['physical_state'] = (int)$ingredient['physical_state'] ?: 1;
Expand Down
2 changes: 1 addition & 1 deletion css/vault.css
Original file line number Diff line number Diff line change
Expand Up @@ -1457,5 +1457,5 @@ th.dt-center, td.dt-center {
}

.highlight {
background-color: yellow !important; /* Change to whatever color you prefer */
background-color: #f5f597 !important; /* Change to whatever color you prefer */
}
7 changes: 4 additions & 3 deletions db/pvault.sql
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";

CREATE TABLE `allergens` (
CREATE TABLE `ingredient_compounds` (
`id` int(11) NOT NULL,
`ing` varchar(255) COLLATE utf8_general_ci NOT NULL,
`name` varchar(255) COLLATE utf8_general_ci NOT NULL,
`cas` varchar(255) COLLATE utf8_general_ci DEFAULT NULL,
`ec` varchar(255) COLLATE utf8_general_ci DEFAULT NULL,
`percentage` DECIMAL(8,4) NOT NULL,
`toDeclare` INT NOT NULL DEFAULT '0',
`GHS` TEXT NOT NULL DEFAULT '-',
`created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

Expand Down Expand Up @@ -446,7 +447,7 @@ ALTER TABLE `users`
ADD PRIMARY KEY (`id`);


ALTER TABLE `allergens`
ALTER TABLE `ingredient_compounds`
ADD PRIMARY KEY (`id`);

ALTER TABLE `bottles`
Expand Down Expand Up @@ -491,7 +492,7 @@ ALTER TABLE `settings`
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

ALTER TABLE `allergens`
ALTER TABLE `ingredient_compounds`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

CREATE TABLE `documents` (
Expand Down
2 changes: 1 addition & 1 deletion db/schema.ver
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.1
10.2
2 changes: 2 additions & 0 deletions db/updates/update_10.1-10.2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
RENAME TABLE `allergens` TO `ingredient_compounds`;
ALTER TABLE `ingredient_compounds` ADD `GHS` TEXT NOT NULL DEFAULT '-' AFTER `toDeclare`;
2 changes: 1 addition & 1 deletion func/calcPerc.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function multi_dim_search($array, $key, $value){
function multi_dim_perc($conn, $form, $ingCas, $qStep) {
foreach ($form as $formula){

if($compos = mysqli_query($conn, "SELECT name,percentage,cas FROM allergens WHERE ing = '".$formula['ingredient']."'")){
if($compos = mysqli_query($conn, "SELECT name,percentage,cas FROM ingredient_compounds WHERE ing = '".$formula['ingredient']."'")){

while($compo = mysqli_fetch_array($compos)){
$cmp[] = $compo;
Expand Down
4 changes: 2 additions & 2 deletions func/genBatchPDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function Code39($xpos, $ypos, $code, $baseline=0.5, $height=5){
$fq = mysqli_query($conn, "SELECT ingredient FROM $formulaTable WHERE fid = '$fid'");
while($ing = mysqli_fetch_array($fq)){
$getIngAlergen = mysqli_fetch_array(mysqli_query($conn, "SELECT name FROM ingredients WHERE name = '".$ing['ingredient']."' AND allergen = '1'"));
$qAll = mysqli_query($conn, "SELECT name FROM allergens WHERE ing = '".$ing['ingredient']."'");
$qAll = mysqli_query($conn, "SELECT name FROM ingredient_compounds WHERE ing = '".$ing['ingredient']."'");

while($getAllergen = mysqli_fetch_array($qAll)){
$allergen[] = $getAllergen['name'];
Expand Down Expand Up @@ -217,7 +217,7 @@ function Code39($xpos, $ypos, $code, $baseline=0.5, $height=5){
}
while ($res_all_ing = mysqli_fetch_array($qAllIng)) {

$bldQ = mysqli_query($conn, "SELECT ing,name,cas,percentage FROM allergens WHERE ing = '".$res_all_ing['ingredient']."'");
$bldQ = mysqli_query($conn, "SELECT ing,name,cas,percentage FROM ingredient_compounds WHERE ing = '".$res_all_ing['ingredient']."'");
while($bld = mysqli_fetch_array($bldQ)){
$pdf->Ln();
$pdf->SetFont('Arial','',8);
Expand Down
3 changes: 2 additions & 1 deletion js/fullformula.view.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,12 @@ $('#schedule_to_make').on('click', '[id*=addTODO]', function () {
if ( data.success ) {
$('#toast-title').html('<i class="fa-solid fa-circle-check mr-2"></i>' + data.success);
$('.toast-header').removeClass().addClass('toast-header alert-success');
$('#schedule_to_make').modal('toggle');

} else {
$('#toast-title').html('<i class="fa-solid fa-circle-exclamation mr-2"></i>' + data.error);
$('.toast-header').removeClass().addClass('toast-header alert-danger');
}
$('#schedule_to_make').modal('toggle');
$('.toast').toast('show');
}
});
Expand Down
28 changes: 20 additions & 8 deletions pages/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,10 @@
echo json_encode($msg);
return;
}
$ingredients = 0;
$ingredients_count = 0;
$suppliers_count = 0;
$ing_suppliers_count = 0;
$ingredient_compounds_count = 0;

$q = mysqli_query($conn, "SELECT * FROM ingredients");
while($res = mysqli_fetch_assoc($q)){
Expand Down Expand Up @@ -311,11 +313,11 @@
$r['molecularWeight'] = (string)$res['molecularWeight'];


$ingredients++;
$ingredients_count++;
$ing[] = $r;

}
$q = mysqli_query($conn, "SELECT * FROM allergens");
$q = mysqli_query($conn, "SELECT * FROM ingredient_compounds");
while($res = mysqli_fetch_assoc($q)){

$c['id'] = (string)$res['id'];
Expand All @@ -324,9 +326,11 @@
$c['cas'] = (string)$res['cas'] ?: 'N/A';
$c['ec'] = (string)$res['ec'] ?: 'N/A';
$c['percentage'] = (double)$res['percentage'];
$c['GHS'] = (string)$res['GHS'];
$c['toDeclare'] = (int)$res['toDeclare'];
$c['created'] = (string)$res['created'];


$ingredient_compounds_count++;
$cmp[] = $c;
}

Expand Down Expand Up @@ -371,13 +375,15 @@
$is['email'] = (string)$res_sup['email']?: 'N/A';

$ingSup[] = $is;
$ing_suppliers_count++;
}


$vd['product'] = $product;
$vd['version'] = $ver;
$vd['ingredients'] = $ingredients;
$vd['suppliers'] = $suppliers_count;
$vd['ingredients'] = $ingredients_count;
$vd['suppliers'] = $ing_suppliers_count;
$vd['ingredient_compounds'] = $ingredient_compounds_count;
$vd['timestamp'] = date('d/m/Y H:i:s');


Expand All @@ -403,6 +409,8 @@
}
$ingredient = 0;
$suppliers_count = 0;
$ingredient_compounds_count = 0;
$ing_suppliers_count = 0;

$q = mysqli_query($conn, "SELECT * FROM ingredients WHERE id=".$_GET['id']."");
while($res = mysqli_fetch_assoc($q)){
Expand Down Expand Up @@ -462,7 +470,7 @@
$ing[] = $r;
}

$q = mysqli_query($conn, "SELECT * FROM allergens WHERE ing ='".$ing['0']['name']."'");
$q = mysqli_query($conn, "SELECT * FROM ingredient_compounds WHERE ing ='".$ing['0']['name']."'");
while($res = mysqli_fetch_assoc($q)){

$c['id'] = (int)$res['id'];
Expand All @@ -471,10 +479,12 @@
$c['cas'] = (string)$res['cas'] ?: 'N/A';
$c['ec'] = (string)$res['ec'] ?: 'N/A';
$c['percentage'] = (double)$res['percentage'];
$c['GHS'] = (string)$res['GHS'];
$c['toDeclare'] = (int)$res['toDeclare'];
$c['created'] = (string)$res['created'];

$cmp[] = $c;
$ingredient_compounds_count++;
}


Expand Down Expand Up @@ -516,13 +526,15 @@
$is['email'] = (string)$res_sup['email'] ?: 'N/A';

$ingSup[] = $is;
$ing_suppliers_count++;
}
}

$vd['product'] = $product;
$vd['version'] = $ver;
$vd['ingredients'] = $ingredient;
$vd['suppliers'] = $suppliers_count;
$vd['suppliers'] = $ing_suppliers_count;
$vd['ingredient_compounds'] = $ingredient_compounds_count;
$vd['timestamp'] = date('d/m/Y H:i:s');


Expand Down
Loading

0 comments on commit 723dd94

Please sign in to comment.