I would like to ask for help with my code.
CODE: SELECT ALL
Code: Select all
//Adjustments Batches //
$AdjustedQty = sqlValue("SELECT QtyJars FROM adjustments1 where BatchesID='{$id}'");
$positive_codes = "'Found-New'";
$OnHandJars = sqlValue("SELECT OnHandJars from batches where BatchesID='{$id}'");
$reason_balance = sqlValue("SELECT sum(if(reason in ({$positive_codes}) $AdjustedQty + $OnHandJars)) ");
sql("UPDATE batches SET OnHandJars='{$reason_balance}' WHERE BatchesID='{$id}'",$eo);
What I'm trying to accomplish is to update my batches.onhandjars when there's an adjustment on quantity.
So the reason codes are "Re-label", "Re-classify", "Found-New", "Missing"
Thanks, Lon