Skip to content

Commit

Permalink
Merge pull request #68 from globaldyne/v6.4
Browse files Browse the repository at this point in the history
V6.4
  • Loading branch information
globaldyne authored May 12, 2023
2 parents f02ebec + 814cd6e commit 11147e4
Show file tree
Hide file tree
Showing 20 changed files with 381 additions and 68 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# CHANGELOG
### Version 6.4
- Fix supplier details edit modal
- Add available var list in SDS Html Editor
- Convert get supplier price function to return json instead of html
- Improve privacy settings in ingredients - a message to let user know that if privacy is enabled, the ingredient data will not be available to other user in the local installation (This is a place holder for a future release)
- Added PV Online in ingredient search provider
- Added option to import single ingredient data from pvonline
- Introducing tokens (pvToken) for users to login to pvOnline - This will be fully migrated in the upcoming releases

### Version 6.3
- Add phpMyAdmin for docker images
- Add a message to notify user that SDS document generation its in preview state
Expand Down
2 changes: 1 addition & 1 deletion VERSION.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.3
6.4
2 changes: 2 additions & 0 deletions core/genDoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

$search = array(
'%LOGO%',
'%BRAND_LOGO%',
'%BRAND_NAME%',
'%BRAND_ADDRESS%',
'%BRAND_EMAIL%',
Expand Down Expand Up @@ -55,6 +56,7 @@

$replace = array(
__PVLOGO__,
__BRANDLOGO__,
$settings['brandName'],
$settings['brandAddress'],
$settings['brandEmail'],
Expand Down
2 changes: 2 additions & 0 deletions css/vault.css
Original file line number Diff line number Diff line change
Expand Up @@ -1083,4 +1083,6 @@ table#tdDataPending.dataTable thead:hover {

.pv_point_gen_color {
color: #23527c;
cursor: pointer !important;
font-style: normal;
}
6 changes: 4 additions & 2 deletions db/pvault.sql
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,10 @@ CREATE TABLE `users` (
`id` int(11) NOT NULL,
`email` varchar(255) COLLATE utf8_general_ci NOT NULL,
`password` varchar(255) COLLATE utf8_general_ci NOT NULL,
`fullName` varchar(255) COLLATE utf8_general_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=COMPACT;
`pvToken` VARCHAR(255) COLLATE utf8_general_ci NULL,
`fullName` varchar(255) COLLATE utf8_general_ci NOT NULL,
`avatar` varchar(255) COLLATE utf8_general_ci NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

CREATE TABLE `pv_online` (
`enabled` INT NOT NULL DEFAULT '0'
Expand Down
2 changes: 1 addition & 1 deletion db/schema.ver
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.3
6.4
2 changes: 2 additions & 0 deletions db/updates/update_6.3-6.4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE `users` ADD `pvToken` VARCHAR(255) NOT NULL AFTER `password`;
ALTER TABLE `users` ADD `avatar` VARCHAR(255) NOT NULL AFTER `fullName`;
21 changes: 21 additions & 0 deletions js/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function insertAtCaret(areaId,text) {
var txtarea = document.getElementById(areaId);
var scrollPos = txtarea.scrollTop;
var strPos = 0;
var br = ((txtarea.selectionStart || txtarea.selectionStart == '0') ? "ff" : (document.selection ? "ie" : false ) );
if (br == "ie") { txtarea.focus();
var range = document.selection.createRange();
range.moveStart ('character', -txtarea.value.length); strPos = range.text.length;
} else if (br == "ff") strPos = txtarea.selectionStart;
var front = (txtarea.value).substring(0,strPos);
var back = (txtarea.value).substring(strPos,txtarea.value.length);
txtarea.value=front+text+back; strPos = strPos + text.length; if (br == "ie") { txtarea.focus();
var range = document.selection.createRange();
range.moveStart ('character', -txtarea.value.length);
range.moveStart ('character', strPos);
range.moveEnd ('character', 0);
range.select();
} else if (br == "ff") { txtarea.selectionStart = strPos; txtarea.selectionEnd = strPos; txtarea.focus();
}
txtarea.scrollTop = scrollPos;
}
6 changes: 3 additions & 3 deletions login.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@

After installing <strong><?=$product?></strong> for the first time, you asked to set a password. This password cannot be retrieved later on as its stored in the database in encrypted format.
<?php if(file_exists('/config/.DOCKER') == TRUE || file_exists('/config/.CLOUD') == TRUE){ ?>
To set a new password, you need to execute the command bellow:
To set a new password for a user, you need to execute the command bellow followed by the user's email you want its password reset:
<p></p>
<pre>reset_pass.sh</pre>
<pre>reset_pass.sh [email protected]</pre>
<?php }else{ ?>
To set a new password, you need manually access your database and set a new password there or remove the user. This will force the system to ask you to create a new user.
To set a new password, you need manually to access your database and set a new password there for the user you want its password reset.
<?php } ?>
</div>
<div class="modal-footer">
Expand Down
9 changes: 8 additions & 1 deletion modules/suppliers/local.json
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
{"id":"local","name":"Local DB","slug":"local","version":"1.0","fileName":"local","icon":"fas fa-database"}
{
"id":"local",
"name":"Local DB",
"slug":"local",
"version":"1.0",
"fileName":"local",
"icon":"fas fa-database"
}
1 change: 1 addition & 0 deletions modules/suppliers/local.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
$filtered = mysqli_fetch_assoc(mysqli_query($conn,"SELECT COUNT(id) AS entries FROM ingredients ".$filter));

$response = array(
"source" => 'local',
"draw" => (int)$_POST['draw'],
"recordsTotal" => (int)$total['entries'],
"recordsFiltered" => (int)$filtered['entries'],
Expand Down
8 changes: 8 additions & 0 deletions modules/suppliers/pvOnline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id":"pvOnline",
"name":"PV Online DB",
"slug":"pvOnline",
"version":"1.0",
"fileName":"pvOnline",
"icon":"fas fa-cloud"
}
86 changes: 86 additions & 0 deletions modules/suppliers/pvOnline.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php
define('__ROOT__', dirname(dirname(__FILE__)));

require_once(__ROOT__.'/inc/sec.php');
require_once(__ROOT__.'/inc/config.php');
require_once(__ROOT__.'/inc/opendb.php');
require_once(__ROOT__.'/inc/settings.php');
require_once(__ROOT__.'/func/pvOnline.php');



$row = $_POST['start']?:0;
$limit = $_POST['length']?:10;
$order_by = $_POST['order_by']?:'name';
$order = $_POST['order_as']?:'ASC';


$s = trim($_POST['search']['value']);
$data = [
'do' => 'ingredients',
'start' => $row,
'length' => $limit,
'order_by' => $order_by,
'order_as' => $order,
's' => $s
];

$output = json_decode(pvPost($pvOnlineAPI, $data));

$rx = array();
foreach ($output->ingredients as $ingredient){
$r['id'] = (int)$ingredient->id;
$r['name'] = (string)filter_var ( $ingredient->name, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$r['cas'] = (string)$ingredient->cas ?: 'N/A';
$r['odor'] = (string)$ingredient->odor ?: 'N/A';
$r['profile'] = (string)$ingredient->profile ?: 'N/A';
$r['physical_state'] = $ingredient->physical_state ?: 1;
$r['category'] = $ingredient->category ?: 0;
$r['type'] = (string)$ingredient->type ?: 'N/A';
$r['IUPAC'] = (string)filter_var ( $ingredient->INCI, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$r['strength'] = (string)$ingredient->strength ?: 'N/A';
$r['purity'] = $ingredient->purity ?: 100;
$r['FEMA'] = (string)$ingredient->FEMA ?: 'N/A';
$r['tenacity'] = (string)$ingredient->tenacity ?: 'N/A';
$r['chemical_name'] = (string)$ingredient->chemical_name ?: 'N/A';
$r['formula'] = (string)$ingredient->formula ?: 'N/A';
$r['flash_point'] = (string)$ingredient->flash_point ?: 'N/A';
$r['appearance'] = (string)$ingredient->appearance ?: 'N/A';
$r['notes'] = (string)$ingredient->notes ?: 'N/A';
$r['allergen'] = $ingredient->allergen ?: 0;
$r['flavor_use'] = $ingredient->flavor_use ?: 0;
$r['einecs'] = (string)$ingredient->einecs ?: 'N/A' ;
$r['usage']['limit'] = $ingredient->cat4 ?: 100;
$r['usage']['reason'] = (string)$ingredient->risk ?: 'N/A';
$r['impact_top'] = $ingredient->impact_top ?: 0;
$r['impact_heart'] = $ingredient->impact_heart ?: 0;
$r['impact_base'] = $ingredient->impact_base ?: 0;

//Only the default supplier will be provided
$r['supplier'][0]['name'] = (string)$ingredient->supplier ?: 'N/A' ;
$r['supplier'][0]['link'] = (string)$ingredient->supplier_link ?: 'N/A' ;
$r['price'] = (double)$ingredient->price ?: 0;

$r['stock'] = (double)0; //Not available in online

$r['info']['byPassIFRA'] = (int)0;//Not available in online


$rx[]=$r;
}

$response = array(
"source" => 'PVOnline',
"draw" => (int)$_POST['draw'],
"recordsTotal" => (int)$output->ingredientsTotal,
"recordsFiltered" => (int)$output->ingredientsFiltered,
"data" => $rx
);

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

header('Content-Type: application/json; charset=utf-8');
echo json_encode($response,JSON_UNESCAPED_UNICODE);
return;
72 changes: 56 additions & 16 deletions pages/editHtmlTmpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,71 @@
</style>
<script src="/js/jquery/jquery.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/helpers.js"></script>

</head>

<body>
<div class="card-body">
<div id="tmpl_inf"></div>
<table width="100%" border="0">
<tr>
<th colspan="2" align="right" valign="top" scope="col"><?=$tmpl['name']?></th>
<tr>
<th scope="col"><textarea id="editor"><?=$tmpl['content']?></textarea></th>
</tr>
</table>
</p>
<div class="alert alert-info">Please refer <a href="https://www.jbparfum.com/knowledge-base/html-templates/" target="_blank">here</a> for special variables syntax</div>
<p>
<input type="submit" name="button" class="btn btn-primary" id="save" value="Save changes">
</p>
<div class="dropdown-divider"></div>
</div>
</div>
</div>
<h3><?=$tmpl['name']?></h3>
<div class="row">
<div class="col-xs-8">
HTML Content:
<textarea class="form-control" name="editor" id="editor" rows="30"><?=$tmpl['content']?></textarea>
</div>
<div class="col-xs-3">
<div class="special-vars">
<strong>Special vars</strong>
<ul id="addvars">
<li><a onclick="insertAtCaret('editor','%LOGO%');" href="#">Add your Logo (IFRA, SDS)</a></li>
<li><a onclick="insertAtCaret('editor','%BRAND_NAME%');" href="#">Add your brand name (IFRA, SDS)</a></li>
<li><a onclick="insertAtCaret('editor','%BRAND_LOGO%');" href="#">Add your brand logo (SDS)</a></li>
<li><a onclick="insertAtCaret('editor','%BRAND_ADDRESS%');" href="#">Add your brand’s address (IFRA, SDS)</a></li>
<li><a onclick="insertAtCaret('editor','%BRAND_EMAIL%');" href="#">Add your email (IFRA, SDS)</a></li>
<li><a onclick="insertAtCaret('editor','%BRAND_PHONE%');" href="#">Add your phone number (IFRA, SDS)</a></li>
<li><a onclick="insertAtCaret('editor','%CUSTOMER_NAME%');" href="#">Add customer's name (IFRA)</a></li>
<li><a onclick="insertAtCaret('editor','%CUSTOMER_ADDRESS%');" href="#">Add customer’s address (IFRA)</a></li>
<li><a onclick="insertAtCaret('editor','%CUSTOMER_EMAIL%');" href="#">Add custtomes email (IFRA)</a></li>
<li><a onclick="insertAtCaret('editor','%CUSTOMER_WEB%');" href="#">Add customer’s website (IFRA)</a></li>
<li><a onclick="insertAtCaret('editor','%PRODUCT_NAME%');" href="#">Add finished product size in ml (IFRA)</a></li>
<li><a onclick="insertAtCaret('editor','%PRODUCT_CONCENTRATION%');" href="#">Add product concentration (IFRA)</a></li>
<li><a onclick="insertAtCaret('editor','%IFRA_AMENDMENT%');" href="#">Add the IFRA amendment number you use (IFRA)</a></li>
<li><a onclick="insertAtCaret('editor','%IFRA_AMENDMENT_DATE%');" href="#">Add the IFRA amendment release date (IFRA)</a></li>
<li><a onclick="insertAtCaret('editor','%PRODUCT_CAT_CLASS%');" href="#">Add the category class of your product (IFRA)</a></li>
<li><a onclick="insertAtCaret('editor','%PRODUCT_TYPE%');" href="#">Add the product type (IFRA)</a></li>
<li><a onclick="insertAtCaret('editor','%PRODUCT_CAT_CLASS%');" href="#">Add the category class of your product (IFRA)</a></li>
<li><a onclick="insertAtCaret('editor','%CURRENT_DATE%');" href="#">Add the current date (IFRA, SDS)</a></li>
<li><a onclick="insertAtCaret('editor','%IFRA_MATERIALS_LIST%');" href="#">Add materials in formula found under the IFRA scope (IFRA)</a></li>
<li><a onclick="insertAtCaret('editor','%INGREDIENT_NAME%');" href="#">Add the ingredient name (SDS)</a></li>
<li><a onclick="insertAtCaret('editor','%CAS%');" href="#">Add ingredient’s CAS number (SDS)</a></li>
<li><a onclick="insertAtCaret('editor','%IUPAC%');" href="#">Add ingredient’s IUPAC data (SDS)</a></li>
<li><a onclick="insertAtCaret('editor','%REACH%');" href="#">Add ingredient’s REACH number (SDS)</a></li>
<li><a onclick="insertAtCaret('editor','%EINECS%');" href="#">Add ingredient’s EINECS - EC (SDS)</a></li>
<li><a onclick="insertAtCaret('editor','%SUPPLIER_NAME%');" href="#">Add ingredient’s supplier name (SDS)</a></li>
<li><a onclick="insertAtCaret('editor','%SUPPLIER_ADDRESS%');" href="#">Add ingredient’s supplier address (SDS)</a></li>
<li><a onclick="insertAtCaret('editor','%SUPPLIER_PO%');" href="#">Add ingredient’s supplier postal code (SDS)</a></li>
<li><a onclick="insertAtCaret('editor','%SUPPLIER_COUNTRY%');" href="#">Add ingredient’s supplier country (SDS)</a></li>
<li><a onclick="insertAtCaret('editor','%SUPPLIER_PHONE%');" href="#">Add ingredient’s supplier phone number (SDS)</a></li>
<li><a onclick="insertAtCaret('editor','%SUPPLIER_URL%');" href="#">Add ingredient’s supplier website (SDS)</a></li>
<li><a onclick="insertAtCaret('editor','%SUPPLIER_EMAIL%');" href="#">Add ingredient’s supplier email (SDS)</a></li>
</ul>
</div>
</div>
</div>
<div class="dropdown-divider"></div>
<div class="alert alert-info">Please refer <a href="https://www.jbparfum.com/knowledge-base/html-templates/" target="_blank">here</a> for special variables syntax</div>
<div class="modal-footer">
<input type="submit" name="button" class="btn btn-primary" id="save" value="Save changes">
</div>
</div>
</div>

</body>
</html>
<script>


$('#save').click(function() {
$.ajax({
url: '/pages/update_data.php',
Expand Down
12 changes: 9 additions & 3 deletions pages/ingSuppliers.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

<h3>Suppliers</h3>
<hr>
<div id="supMsg"></div>
<div class="card-body">
<div class="text-right">
<div class="btn-group">
Expand Down Expand Up @@ -354,7 +355,7 @@ function sActions(data, type, row){
s.Link = $(this).attr('data-link');
s.Size = $(this).attr('data-size');

$('#ingMsg').html('<div class="alert alert-info alert-dismissible"><a href="#" class="close" data-dismiss="alert" aria-label="close">x</a><strong>Please wait...</strong></div>');
$('#supMsg').html('<div class="alert alert-info"><strong>Please wait, trying to fetch supplier data...</strong></div>');
$('#' + s.ID).html('<img src="/img/loading.gif"/>');
$.ajax({
url: 'update_data.php',
Expand All @@ -366,9 +367,14 @@ function sActions(data, type, row){
ingSupplierID: s.ID,
ingID: '<?=$ingID?>'
},
dataType: 'html',
dataType: 'json',
success: function (data) {
$('#ingMsg').html(data);
if (data.success) {
var msg = '<div class="alert alert-success alert-dismissible"><a href="#" class="close" data-dismiss="alert" aria-label="close">x</a>' + data.success + '</div>';
}else{
var msg = '<div class="alert alert-danger alert-dismissible"><a href="#" class="close" data-dismiss="alert" aria-label="close">x</a>' + data.error + '</div>';
}
$('#supMsg').html(msg);
reload_sup_data();
}
});
Expand Down
Loading

0 comments on commit 11147e4

Please sign in to comment.