Question: I can't seem to get the php program to write the results to the fshp and fbo files under the function write files section at
I can't seem to get the php program to write the results to the fshp and fbo files under the function write files section at the bottom of the code to complete writing to the files. I am not allowed to use global.
// END MAINLINE function PrepareFiles(&$fshp,&$fbo ) { $fshp = fopen("shipped.txt", "w") or die("shipped not opened"); fprintf($fshp," SHIPPED REPORT "); fprintf($fshp," Order Id Item Id Shipped Message "); $fbo = fopen("backorder.txt", "w") or die("backorder not opened"); fprintf($fbo," BACK ORDER REPORT "); fprintf($fbo," Order Id Item Id Backordered "); } function DoCalcs($qtyOnHand,$qtyRequested, &$qtyShipped, &$qtyBackOrdered, &$message) { printf(" DoCalcs "); /// if($qtyRequested <= $qtyOnHand) { $qtyShipped = $qtyRequested; $qtyBackordered = 0; $message = "Fully Filled"; } else { if($qtyOnHand !=0) { $qtyShipped = $qtyOnHand; $qtyBackOrdered = $qtyRequested - $qtyOnHand; $message = "Partially Filled"; } else { $qtyShipped = 0; $qtyBackOrdered = $qtyRequested; $message = "Out of Stock"; } } }
function WriteFiles($fship, $fbo, $orderId, $itemId, $qtyOnHand, $qtyRequested, &$qtyShipped, &$qtyBackOrdered, &$message) { printf(" WriteFiles "); fprintf($fshp, "$orderId $itemId $qtyShipped $message "); fprintf($fbo, "$orderId $itemId $qtyBackOrdered ");
}
?>
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
