-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #188 from globaldyne/v11.5
V11.5
- Loading branch information
Showing
14 changed files
with
343 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
11.4 | ||
11.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
11.4 | ||
11.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,4 +41,4 @@ function getSupplierByID($sID,$conn){ | |
return $result; | ||
} | ||
|
||
?> | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,4 +157,4 @@ | |
echo json_encode($response,JSON_UNESCAPED_UNICODE); | ||
return; | ||
|
||
?> | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,96 @@ | ||
<?php | ||
define('__ROOT__', dirname(dirname(__FILE__))); | ||
//define('__ROOT__', dirname(dirname(__FILE__))); | ||
|
||
require_once(__ROOT__.'/inc/sec.php'); | ||
require_once(__ROOT__.'/inc/opendb.php'); | ||
require_once(__ROOT__.'/inc/settings.php'); | ||
require_once(__ROOT__.'/func/pvOnline.php'); | ||
|
||
|
||
$row = isset($_POST['start']) ? (int)$_POST['start'] : 0; | ||
$limit = isset($_POST['length']) ? (int)$_POST['length'] : 10; | ||
$order_by = isset($_POST['order_by']) ? $_POST['order_by'] : 'name'; | ||
$order = isset($_POST['order_as']) ? $_POST['order_as'] : 'ASC'; | ||
|
||
$row = $_POST['start']?:0; | ||
$limit = $_POST['length']?:10; | ||
$order_by = $_POST['order_by']?:'name'; | ||
$order = $_POST['order_as']?:'ASC'; | ||
// Trim and sanitize search input | ||
$s = isset($_POST['search']['value']) ? trim($_POST['search']['value']) : ''; | ||
|
||
// Prepare data array for API request | ||
$data = [ | ||
'request' => 'ingredients', | ||
'start' => $row, | ||
'length' => $limit, | ||
'order_by' => $order_by, | ||
'order_as' => $order, | ||
'src' => 'PV_PRO', | ||
'search[value]' => $s | ||
]; | ||
|
||
$s = trim($_POST['search']['value']); | ||
$data = [ | ||
'request' => 'ingredients', | ||
'start' => $row, | ||
'length' => $limit, | ||
'order_by' => $order_by, | ||
'order_as' => $order, | ||
'src' => 'PV_PRO', | ||
'search[value]=' => $s | ||
]; | ||
|
||
// Make API request and decode the JSON response | ||
$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 ?: 'Uknown'; | ||
$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; | ||
|
||
|
||
$r['stock'] = (double)0; //Not available in online | ||
$r['info']['byPassIFRA'] = (int)0;//Not available in online | ||
|
||
// Initialize response array | ||
$rx = []; | ||
if (isset($output->ingredients) && is_array($output->ingredients)) { | ||
foreach ($output->ingredients as $ingredient) { | ||
if (empty($ingredient->name)) { | ||
continue; | ||
} | ||
|
||
$rx[]=$r; | ||
$r = [ | ||
'id' => (int) $ingredient->id, | ||
'name' => (string) filter_var($ingredient->name, FILTER_SANITIZE_FULL_SPECIAL_CHARS), | ||
'cas' => (string) ($ingredient->cas ?: 'N/A'), | ||
'odor' => (string) ($ingredient->odor ?: 'N/A'), | ||
'profile' => (string) ($ingredient->profile ?: 'Unknown'), | ||
'physical_state' => (int) ($ingredient->physical_state ?: 1), | ||
'category' => (int) ($ingredient->category ?: 0), | ||
'type' => (string) ($ingredient->type ?: 'N/A'), | ||
'IUPAC' => (string) filter_var($ingredient->INCI, FILTER_SANITIZE_FULL_SPECIAL_CHARS), | ||
'strength' => (string) ($ingredient->strength ?: 'N/A'), | ||
'purity' => (float) ($ingredient->purity ?: 100), | ||
'FEMA' => (string) ($ingredient->FEMA ?: 'N/A'), | ||
'tenacity' => (string) ($ingredient->tenacity ?: 'N/A'), | ||
'chemical_name' => (string) ($ingredient->chemical_name ?: 'N/A'), | ||
'formula' => (string) ($ingredient->formula ?: 'N/A'), | ||
'flash_point' => (string) ($ingredient->flash_point ?: 'N/A'), | ||
'appearance' => (string) ($ingredient->appearance ?: 'N/A'), | ||
'notes' => (string) ($ingredient->notes ?: 'N/A'), | ||
'allergen' => (int) ($ingredient->allergen ?: 0), | ||
'flavor_use' => (int) ($ingredient->flavor_use ?: 0), | ||
'einecs' => (string) ($ingredient->einecs ?: 'N/A'), | ||
'usage' => [ | ||
'limit' => (float) ($ingredient->cat4 ?: 100), | ||
'reason' => (string) ($ingredient->risk ?: 'N/A') | ||
], | ||
'impact_top' => (int) ($ingredient->impact_top ?: 0), | ||
'impact_heart' => (int) ($ingredient->impact_heart ?: 0), | ||
'impact_base' => (int) ($ingredient->impact_base ?: 0), | ||
'stock' => 0.0, // Stock not available from online source | ||
'info' => [ | ||
'byPassIFRA' => 0 // Not available from online source | ||
] | ||
]; | ||
|
||
$rx[] = $r; | ||
} | ||
} | ||
|
||
$response = array( | ||
"source" => 'PVOnline', | ||
"draw" => (int)$_POST['draw'], | ||
"recordsTotal" => (int)$output->ingredientsTotal, | ||
"recordsFiltered" => (int)$output->ingredientsFiltered, | ||
"data" => $rx | ||
); | ||
// Prepare final response | ||
$response = [ | ||
'source' => 'PVOnline', | ||
'draw' => isset($_POST['draw']) ? (int) $_POST['draw'] : 0, | ||
'recordsTotal' => (int) ($output->ingredientsTotal ?? 0), | ||
'recordsFiltered' => (int) ($output->ingredientsFiltered ?? 0), | ||
'data' => $rx | ||
]; | ||
|
||
if(empty($rx)){ | ||
$response['data'] = []; | ||
// If no data found, ensure an empty array is returned | ||
if (empty($rx)) { | ||
$response['data'] = []; | ||
} | ||
|
||
// Send the response as JSON | ||
header('Content-Type: application/json; charset=utf-8'); | ||
echo json_encode($response,JSON_UNESCAPED_UNICODE); | ||
return; | ||
echo json_encode($response, JSON_UNESCAPED_UNICODE); | ||
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.