Skip to content

Commit

Permalink
Merge pull request #2 from globaldyne/v2.8
Browse files Browse the repository at this point in the history
V2.8
  • Loading branch information
globaldyne authored Apr 28, 2021
2 parents 5bbefc8 + 464823c commit f1ce1b6
Show file tree
Hide file tree
Showing 51 changed files with 1,664 additions and 891 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.js linguist-detectable=false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ inc/config.php
*.swp
t.php
tests/
searchTGSC.php
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
# CHANGELOG
### Version 2.8
Formula CSV Import improvements
Added protection from accidental deletion in formulas
IFRA Library import improvements
Various bug fixes
Fix data table in formulas listing
Fix a bug preventing CAS number to be shown in batch PDF
Label print improvements
Multi-dimensional ingredient lookup in alleregens and re-calculate the usage percentages
Add measurement units
Add category image
Notes summary in formula per ingrdient profile
Category lookup by ID
Add category image in ingredients list
Add pubChem function
IFRA certification improvements
Add Molecular Weight for ingredients
Add Mass for ingredients
Remove legend/share if formula is empty
Add update instructions link
Add auto-update function when non docker
Add option for notes per ingredient in formula
Making username case insensitive
Making ingredient name case insensitive

### Version 2.7
Making sure the percentage symbol is striped out from allergens quantity
Create entry in ingredients from allergens
Expand Down
39 changes: 21 additions & 18 deletions INSTALL.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
LINUX
------------

****Assuming you already have a working php/mysql system configured.


Copy/clone the repo under your web server's home dir (eg. /var/www/)
*Highly recomended to create a vhost

Create a new db eg. pvault and import the schema located under db/ folder

Edit inc/config.php and update it with your db details
*Higly recomended to create a new user with permissions only to the pvault db.


To Enable label printing support, additional software is required:

https://github.com/pklaus/brother_ql
LINUX
------------

****Assuming you already have a working php/mysql system configured.


Download or clone the repo under your web server's home dir (eg. /var/www/)
*Highly recomended to create a vhost

Create a new db eg. pvault and a user with admin rights to it

Open your web browser to you server's url and follow the instruction on the installation wizard.

For more info please refer to:

https://www.jbparfum.com/knowledge-base/


To Enable label printing support, additional software is required:

https://github.com/pklaus/brother_ql
2 changes: 1 addition & 1 deletion VERSION.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7
2.8
51 changes: 47 additions & 4 deletions css/vault.css
Original file line number Diff line number Diff line change
Expand Up @@ -321,16 +321,16 @@ tr.strikeout td:before {

@keyframes load {
0% {
content: 'Loading';
content: 'Blending';
}
33% {
content: 'Loading.';
content: 'Blending.';
}
67% {
content: 'Loading..';
content: 'Blending..';
}
100% {
content: 'Loading...';
content: 'Blending...';
}
}

Expand All @@ -344,3 +344,46 @@ a:hover{
.odd_ing {
background-color: #EEE !important;
}

.modal-ifra {
width: 800px;
max-width: 800px;
margin: auto;
}

.img_ing {
max-height: 40px;
}

.img_ing_sel {
max-height: 30px;
max-width: 30px;
padding: 0 10px 0 0;
}

figure {
display: inline;
border: none;
margin: 25px;
}
figure img {
vertical-align: top;
}
figure figcaption {
border: none;
text-align: center;
}

formula td, table.table th {
white-space: revert;
}

#notes_summary_view td {
display: inline-block;
}

.col-md-6 {
width: 50%;
height: fit-content;
}

19 changes: 13 additions & 6 deletions db/pvault.sql
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ CREATE TABLE `formulas` (
`ingredient_id` varchar(11) COLLATE utf8_bin DEFAULT NULL,
`concentration` decimal(5,2) DEFAULT 100.00,
`dilutant` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`quantity` decimal(8,3) DEFAULT NULL
`quantity` decimal(8,3) DEFAULT NULL,
`notes` varchar(11) COLLATE utf8_bin DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

DROP TABLE IF EXISTS `makeFormula`;
Expand Down Expand Up @@ -88,7 +89,9 @@ CREATE TABLE `formulasMetaData` (
`sex` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`notes` text COLLATE utf8_bin DEFAULT NULL,
`created` timestamp NOT NULL DEFAULT current_timestamp(),
`image` varchar(255) COLLATE utf8_bin NOT NULL
`image` varchar(255) COLLATE utf8_bin NOT NULL,
`isProtected` INT NULL DEFAULT '0',
`defView` INT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

DROP TABLE IF EXISTS `IFRALibrary`;
Expand Down Expand Up @@ -139,7 +142,8 @@ DROP TABLE IF EXISTS `ingCategory`;
CREATE TABLE `ingCategory` (
`id` int(11) NOT NULL,
`name` varchar(255) COLLATE utf8_bin NOT NULL,
`notes` text COLLATE utf8_bin DEFAULT NULL
`notes` text COLLATE utf8_bin DEFAULT NULL,
`image` LONGTEXT COLLATE utf8_bin NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

DROP TABLE IF EXISTS `ingProfiles`;
Expand All @@ -157,7 +161,7 @@ INSERT INTO `ingProfiles` (`id`, `name`, `notes`) VALUES
DROP TABLE IF EXISTS `ingredients`;
CREATE TABLE `ingredients` (
`id` int(11) NOT NULL,
`name` varchar(255) COLLATE utf8_bin NOT NULL,
`name` varchar(255) COLLATE utf8_general_ci NOT NULL,
`INCI` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`type` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`strength` varchar(255) COLLATE utf8_bin DEFAULT NULL,
Expand Down Expand Up @@ -207,7 +211,8 @@ CREATE TABLE `ingredients` (
`impact_base` varchar(10) COLLATE utf8_bin DEFAULT NULL,
`usage_type` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`noUsageLimit` INT NULL DEFAULT '0',
`isPrivate` INT NULL DEFAULT '0',
`isPrivate` INT NULL DEFAULT '0',
`molecularWeight` VARCHAR(255) NULL,
`created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

Expand Down Expand Up @@ -290,7 +295,9 @@ CREATE TABLE `settings` (
`pubChem` int(11) DEFAULT NULL,
`chkVersion` int(11) DEFAULT NULL,
`qStep` INT(5) NOT NULL DEFAULT '2',
`pubchem_view` VARCHAR(4) NOT NULL DEFAULT '2d',
`pubchem_view` VARCHAR(4) NOT NULL DEFAULT '2d',
`mUnit` VARCHAR(10) NOT NULL DEFAULT 'ml',
`multi_dim_perc` INT NOT NULL DEFAULT '0',
`defCatClass` VARCHAR(255) NOT NULL DEFAULT 'cat4'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

Expand Down
2 changes: 1 addition & 1 deletion db/schema.ver
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7
2.8
8 changes: 8 additions & 0 deletions db/updates/update_2.7-2.8.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ALTER TABLE `formulasMetaData` ADD `isProtected` INT NOT NULL DEFAULT '0' AFTER `image`;
ALTER TABLE `settings` ADD `multi_dim_perc` INT NOT NULL DEFAULT '0' AFTER `pubchem_view`;
ALTER TABLE `settings` ADD `mUnit` VARCHAR(10) NOT NULL DEFAULT 'ml' AFTER `multi_dim_perc`;
ALTER TABLE `ingCategory` ADD `image` LONGTEXT NULL AFTER `notes`;
ALTER TABLE `ingredients` ADD `molecularWeight` VARCHAR(255) NULL AFTER `isPrivate`;
ALTER TABLE `formulas` ADD `notes` VARCHAR(255) NULL AFTER `quantity`;
ALTER TABLE `formulasMetaData` ADD `defView` INT NOT NULL DEFAULT '1' COMMENT '1 = Ingredient properties, 2 = Notes' AFTER `isProtected`;
ALTER TABLE `ingredients` CHANGE `name` `name` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
16 changes: 16 additions & 0 deletions func/arrFilter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
if (!defined('pvault_panel')){ die('Not Found');}

function arrFilter($arr){
$result = array();

foreach($arr as $value){
$name = $value['name'];
$result[$name]['name'] = $name;
$result[$name]['image'] = $value['image'];
}

return array_values($result);
}

?>
68 changes: 56 additions & 12 deletions func/calcPerc.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,57 @@
<?php
if (!defined('pvault_panel')){ die('Not Found');}

function calcPerc($formula, $profile, $percent, $conn){
$formula_q = mysqli_query($conn, "SELECT ingredient FROM formulas WHERE name = '$formula'");
while ($formula = mysqli_fetch_array($formula_q)) {
$ing_q = mysqli_fetch_array(mysqli_query($conn, "SELECT profile FROM ingredients WHERE name = '".$formula['ingredient']."'"));
$prf[] = $ing_q['profile'];
}
$number = array_count_values($prf);
return ($number[$profile] / $percent) * 100;
}
<?php
if (!defined('pvault_panel')){ die('Not Found');}

function calcPerc($formula, $profile, $percent, $conn){
$formula_q = mysqli_query($conn, "SELECT ingredient FROM formulas WHERE name = '$formula'");
while ($formula = mysqli_fetch_array($formula_q)) {
$ing_q = mysqli_fetch_array(mysqli_query($conn, "SELECT profile FROM ingredients WHERE name = '".$formula['ingredient']."'"));
$prf[] = $ing_q['profile'];
}
if($prf){
$number = array_count_values($prf);
return ($number[$profile] / $percent) * 100;
}
return;
}

function multi_dim_search($array, $key, $value){
$results = array();

if (is_array($array)) {
if (isset($array[$key]) && $array[$key] == $value) {
$results[] = $array;
}

foreach ($array as $subarray) {
$results = array_merge($results, multi_dim_search($subarray, $key, $value));
}

}

return $results;
}

function multi_dim_perc($conn, $form) {
foreach ($form as $formula){

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

while($allgIng_res = mysqli_fetch_array($allIngQuery)){
$allgIng[] = $allgIng_res;
}

foreach ($allgIng as $aa){
$arrayLength = count($aa);
$i = 0;
while ($i < $arrayLength){

$c = multi_dim_search($aa, 'name', $formula['ingredient'])[$i];
$conc[$formula['ingredient']] += number_format($formula['quantity'] / 100 * $c['percentage'], 3);

$i++;
}
}
}
return array_unique(array_merge(array_filter($conc)));
}
?>
14 changes: 10 additions & 4 deletions func/checkVer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@
function checkVer($app_ver) {
if($app_ver){
$githubVer = 'https://github.com/raw/globaldyne/parfumvault/master/VERSION.md';
$gitHubRep = 'https://www.jbparfum.com/features/';

$docUrl = 'https://www.jbparfum.com/knowledge-base/how-to-update-pv-to-its-latest-version/';
$data = trim(pv_file_get_contents($githubVer));
if($app_ver < $data){
echo '<div class="alert alert-info alert-dismissible"><a href="#" class="close" data-dismiss="alert" aria-label="close">x</a><strong>New <a href="'.$gitHubRep.'" target="_blanc">version ('.$data.')</a> is availale!</strong></div>';
$gitHubRep = 'https://github.com/globaldyne/parfumvault/archive/refs/tags/v'.$data.'.zip';

if($app_ver < $data){
if(file_exists('.DOCKER') == TRUE){
$r = '<div class="alert alert-info alert-dismissible"><a href="#" class="close" data-dismiss="alert" aria-label="close">x</a><strong>New <a href="'.$gitHubRep.'" target="_blank">version ('.$data.')</a> is availale!</strong> Please refer <a href="'.$docUrl.'" target="_blank">here</a> for update instructions.</div>';
}else{
$r = '<div class="alert alert-info alert-dismissible"><a href="#" class="close" data-dismiss="alert" aria-label="close">x</a><strong>New <a href="'.$gitHubRep.'" target="_blank">version ('.$data.')</a> is availale!</strong> <a href="?do=UpgradeCore">Update Now</a></div>';
}
}
}

return $r;
}
?>
7 changes: 4 additions & 3 deletions func/formulaProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function formulaProfile($conn, $profile, $sex){
$formulas_n = mysqli_query($conn, "SELECT * FROM formulasMetaData WHERE profile = '$profile' OR sex = '$sex' ORDER by name DESC");
}
?>
<table width="100%" border="0" cellspacing="0" id="tdData" class="table table-striped table-bordered table-sm">
<table width="100%" border="0" cellspacing="0" id="tdData<?=$profile?>" class="table table-striped table-bordered table-sm">
<thead>
<tr>
<th width="20%">Formula Name</th>
Expand All @@ -21,11 +21,12 @@ function formulaProfile($conn, $profile, $sex){
<tbody>
<?php while ($formula = mysqli_fetch_array($formulas_n)) { ?>
<tr>
<td align="center"><a href="?do=Formula&name=<?php echo $formula['name']; ?>"><?php echo $formula['name'];?></a></td>
<td align="center"><?php if($formula['isProtected']){?><a class="fas fa-lock"><?php } ?></a>&nbsp;<a href="?do=Formula&name=<?php echo $formula['name']; ?>"><?php echo $formula['name'];?></a></td>
<?php $meta = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM formulasMetaData WHERE name = '".$formula['name']."'"));?>
<td align="center"><a href="pages/getFormMeta.php?id=<?php echo $meta['id']; ?>" class="fas fa-comment-dots popup-link"></a></td>
<td align="center"><?php echo $meta['created'];?></td>
<td align="center"><a href="javascript:addTODO('<?php echo $formula['fid']; ?>')" class="fas fa-list" rel="tipsy" title="Add <?php echo $formula['name']; ?> to the make list" ></a> &nbsp; <a href="javascript:cloneMe('<?php echo $formula['name']; ?>')" class="fas fa-copy" rel="tipsy" title="Clone <?php echo $formula['name']; ?>"></a> &nbsp; <a href="javascript:deleteMe('<?php echo $formula['fid']; ?>')" onclick="return confirm('Delete <?php echo $formula['name']; ?> Formula?')" class="fas fa-trash" rel="tipsy" title="Delete <?php echo $formula['name']; ?>"></a></td></tr>
<td align="center"><a href="javascript:addTODO('<?php echo $formula['fid']; ?>')" class="fas fa-list" rel="tipsy" title="Add <?php echo $formula['name']; ?> to the make list" ></a> &nbsp; <a href="javascript:cloneMe('<?php echo $formula['name']; ?>')" class="fas fa-copy" rel="tipsy" title="Clone <?php echo $formula['name']; ?>"></a> &nbsp; <a href="javascript:deleteMe('<?php echo $formula['fid']; ?>')" onclick="return confirm('Delete <?php echo $formula['name']; ?> Formula?')" class="fas fa-trash" rel="tipsy" title="Delete <?php echo $formula['name']; ?>"></a></td>
</tr>
<?php } ?>
</tbody>
</table>
Expand Down
Loading

0 comments on commit f1ce1b6

Please sign in to comment.