Skip to content

Commit

Permalink
Merge pull request #178 from globaldyne/v10.7
Browse files Browse the repository at this point in the history
V10.7
  • Loading branch information
globaldyne authored Aug 2, 2024
2 parents 467340e + ea5a36d commit 9f32d63
Show file tree
Hide file tree
Showing 17 changed files with 850 additions and 463 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
# CHANGELOG
### Version 10.7
- Removed ingredient purity and dilutant from Finished Product page for cleaner view
- Moved IFRA doc to a modal window
- Added a print button for the generated IFRA Doc
- Fix IFRA Document failing to be generated
- Formula Make page refactor
- Lids page minor update
- Added a pending materials page to list all pending materials and their quantity required for the pending formulas
- todo.php has been renamed to scheduledFormulas.php
- Add suppliers in pending formulas backend
- Choose which supplier you updating the stock when making a formula
- Show available stock from all the available suppliers when making a formula, instead of the preferred one only

### Version 10.6
- Ingredient Where Used page minor improvements
- Ingredient Usage & Limits page minor improvements
Expand Down
2 changes: 1 addition & 1 deletion VERSION.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.6
10.7
50 changes: 50 additions & 0 deletions core/list_pending_materials_data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
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/getIngSupplier.php');

$q = mysqli_query($conn, "SELECT name,ingredient,ingredient_id,quantity FROM makeFormula WHERE toAdd = '1' AND skip = '0'");
while($res = mysqli_fetch_array($q)){
$m[] = $res;
}

foreach ($m as $material) {
$ing = mysqli_fetch_array(mysqli_query($conn,"SELECT cas FROM ingredients WHERE id = '".$material['ingredient_id']."'"));

$inventory = mysqli_fetch_array(mysqli_query($conn, "SELECT SUM(stock) OVER() AS stock, mUnit FROM suppliers WHERE ingID = '".$material['ingredient_id']."'"));

$r['formula'] = (string)$material['name'];
$r['ingredient'] = (string)$material['ingredient'];
$r['quantity'] = (string)$material['quantity'];
$r['cas'] = (string)$ing['cas'] ?: "N/A";

$r['inventory']['stock'] = (float)$inventory['stock'] ?: 0;
$r['inventory']['mUnit'] = (string)$inventory['mUnit'] ?: $settings['mUnit'];

if($a = getIngSupplier($material['ingredient_id'],0,$conn)){
$j = 0;
unset($r['supplier']);
foreach ($a as $b){
$r['supplier'][$j]['name'] = (string)$b['name'];
$r['supplier'][$j]['link'] = (string)$b['supplierLink'];
$r['supplier'][$j]['status'] = (int)$b['status'];
$j++;
}
}else{
$r['supplier'] = null;
}

$response['data'][] = $r;
}

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

header('Content-Type: application/json; charset=utf-8');
echo json_encode($response);
return;
?>
36 changes: 21 additions & 15 deletions core/pending_formulas_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,36 +44,42 @@
}

foreach ($rs as $rq) {
$gING = mysqli_fetch_array(mysqli_query($conn, "SELECT cas,odor FROM ingredients WHERE name = '".$rq['ingredient']."'"));
$inventory = mysqli_fetch_array(mysqli_query($conn, "SELECT stock,mUnit FROM suppliers WHERE ingID = '".$rq['ingredient_id']."' AND preferred = '1'"));
$gING = mysqli_fetch_array(mysqli_query($conn, "SELECT cas, odor FROM ingredients WHERE name = '".$rq['ingredient']."'"));
$inventory = mysqli_fetch_array(mysqli_query($conn, "SELECT ingSupplierID, SUM(stock) OVER() AS stock, mUnit FROM suppliers WHERE ingID = '".$rq['ingredient_id']."'"));
$supplier = mysqli_fetch_array(mysqli_query($conn, "SELECT id, name FROM ingSuppliers WHERE id = '".$inventory['ingSupplierID']."'"));

$repq = mysqli_fetch_array(mysqli_query($conn, "SELECT name FROM ingredients WHERE id = '".$rq['replacement_id']."'"));

$r['id'] = (int)$rq['id'];
$r['fid'] = (string)$rq['fid'];
$r['repID'] = (string)$rq['replacement_id'];
$r['repName'] = (string)$repq['name'];
$r['name'] = (string)$rq['name'];
$r['ingredient'] = (string)$rq['ingredient'];
$r['ingredient'] = (string)$rq['ingredient'];
$r['ingID'] = (int)$rq['ingredient_id'];
$r['cas'] = (string)$gING['cas']?:'N/A';
$r['odor'] = (string)$gING['odor']?:'N/A';

$r['cas'] = (string)$gING['cas'] ?: 'N/A';
$r['odor'] = (string)$gING['odor'] ?: 'N/A';
$r['concentration'] = (float)$rq['concentration'];
$r['dilutant'] = (string)$rq['dilutant'] ?: 'None';
$r['quantity'] = number_format((float)$rq['quantity'], $settings['qStep'],'.', '') ?: 0;
$r['originalQuantity'] = number_format((float)$rq['originalQuantity'], $settings['qStep'],'.', '') ?: 0;
$r['overdose'] = number_format((float)$rq['overdose'], $settings['qStep'],'.', '') ?: 0;

$r['quantity'] = number_format((float)$rq['quantity'], $settings['qStep'], '.', '') ?: 0;
$r['originalQuantity'] = number_format((float)$rq['originalQuantity'], $settings['qStep'], '.', '') ?: 0;
$r['overdose'] = number_format((float)$rq['overdose'], $settings['qStep'], '.', '') ?: 0;
$r['inventory']['stock'] = (float)$inventory['stock'] ?: 0;
$r['inventory']['mUnit'] = (string)$inventory['mUnit'] ?: $settings['mUnit'];

$r['inventory'][]['supplier'] = [
'name' => (string)$supplier['name'],
'id' => (string)$supplier['id']
];

$r['toAdd'] = (int)$rq['toAdd'];
$r['toSkip'] = (int)$rq['skip'];



$rx[]=$r;

$rx[] = $r;
}

foreach ($rsq as $rq) {
$mg['total_mg'] += $rq['quantity'];
}
Expand Down
2 changes: 1 addition & 1 deletion db/schema.ver
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.6
10.7
21 changes: 11 additions & 10 deletions func/genBatchPDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,17 @@ 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,$defPercentage FROM ingredient_compounds WHERE ing = '".$res_all_ing['ingredient']."'");
while($bld = mysqli_fetch_array($bldQ)){
$pdf->Ln();
$pdf->SetFont('Arial','',8);

$pdf->Cell(68,8,$bld['ing'],1,0,'C');

$pdf->Cell(68,8,$bld['name'],1,0,'C');
$pdf->Cell(68,8,$bld['cas'],1,0,'C');
$pdf->Cell(68,8,$bld[$defPercentage],1,0,'C');
if($bldQ = mysqli_query($conn, "SELECT ing,name,cas,$defPercentage FROM ingredient_compounds WHERE ing = '".$res_all_ing['ingredient']."'")){
while($bld = mysqli_fetch_array($bldQ)){
$pdf->Ln();
$pdf->SetFont('Arial','',8);

$pdf->Cell(68,8,$bld['ing'],1,0,'C');

$pdf->Cell(68,8,$bld['name'],1,0,'C');
$pdf->Cell(68,8,$bld['cas'],1,0,'C');
$pdf->Cell(68,8,$bld[$defPercentage],1,0,'C');
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function chkUpdate() {

<li class="nav-item">
<?php
if($_GET['do'] == 'listFormulas' || $_GET['do'] == 'genFinishedProduct' || $_GET['do'] == 'compareFormulas' || $_GET['do'] == 'Formula' || $_GET['do'] == 'sellFormula' || $_GET['do'] == 'todo' || $_GET['do'] == 'batches' ){
if($_GET['do'] == 'listFormulas' || $_GET['do'] == 'genFinishedProduct' || $_GET['do'] == 'compareFormulas' || $_GET['do'] == 'Formula' || $_GET['do'] == 'sellFormula' || $_GET['do'] == 'scheduledFormulas' || $_GET['do'] == 'batches' ){
$expand_f = 'show';
$class_f = '';
$aria_f = 'true';
Expand All @@ -204,7 +204,7 @@ function chkUpdate() {
<a class="collapse-item <?php if($_GET['do'] == 'compareFormulas'){ echo 'active';}?>" href="/?do=compareFormulas">Compare Formulas</a>
<a class="collapse-item <?php if($_GET['do'] == 'genFinishedProduct'){ echo 'active';}?>" href="/?do=genFinishedProduct">Finished Product</a>
<a class="collapse-item <?php if($_GET['do'] == 'sellFormula'){ echo 'active';}?>" href="/?do=sellFormula">Sell Formula</a>
<a class="collapse-item <?php if($_GET['do'] == 'todo'){ echo 'active';}?>" href="/?do=todo">Scheduled Formulas <span class="badge badge-danger badge-counter"><?php echo countPending(NULL, NULL, $conn);?></span></a>
<a class="collapse-item <?php if($_GET['do'] == 'scheduledFormulas'){ echo 'active';}?>" href="/?do=scheduledFormulas">Scheduled Formulas <span class="badge badge-danger badge-counter"><?php echo countPending(NULL, NULL, $conn);?></span></a>
<a class="collapse-item <?php if($_GET['do'] == 'batches'){ echo 'active';}?>" href="/?do=batches">Batch history</a>

</div>
Expand Down Expand Up @@ -312,8 +312,8 @@ function chkUpdate() {
require_once(__ROOT__.'/pages/addLid.php');
}elseif($_GET['do'] == 'batches'){
require_once(__ROOT__.'/pages/views/formula/batches.php');
}elseif($_GET['do'] == 'todo'){
require_once(__ROOT__.'/pages/todo.php');
}elseif($_GET['do'] == 'scheduledFormulas'){
require_once(__ROOT__.'/pages/scheduledFormulas.php');
}elseif($_GET['do'] == 'cart'){
require_once(__ROOT__.'/pages/cart.php');
}elseif($_GET['do'] == 'suppliers'){
Expand Down
Loading

0 comments on commit 9f32d63

Please sign in to comment.