ijustdidit2011 Posted March 9, 2008 Share Posted March 9, 2008 I think im so lost im dead in a ditch somewhere! Trying to write basic inventory program and i cant get it to get out to the other files and i think i have screwed up the functions! <?php //main $ordernumber=0; $itemID= ""; $qtyOnHand =0; $qtyRequested= 0; $qtyShipped = 0; $qtyBO = 0; $message = ""; $fileBo; $fileshipped; prepShippedFile($fileshipped); prepBoFile($fileBo); print("\nEnter the order number or 0 to exit: "); fscanf(STDIN,"%d", $ordernumber); while($ordernumber !=0) { print("\n a new order . . . "); print("\nEnter the Quantity for item: "); fscanf(STDIN,"%d", $qtyRequested); print("\nEnter the Quantity in store: "); fscanf(STDIN,"%d", $qtyOnHand); print("\nEnter the item id or 0 to exit order: "); fscanf(STDIN,"%s", $itemID); while($itemID !="0") { doCalcs(&$qtyRequested,$qtyOnHand,$qtyShipped,$qtyBO,$message); writeReports($fileshipped,$fileBo,$itemID,$qtyShipped,$qtyBO); print("\nEnter the item id or 0 to exit order: "); fscanf(STDIN,"%s", $itemID); } print("\nEnter the order number or 0 to exit: "); fscanf(STDIN,"%d", $ordernumber); } //end main function prepShippedFile(&$fileshipped) { $fileshipped = fopen ("shipped.txt",'w') or die ("no file created"); fprintf($fileshipped, "\n SHIPPED REPORT\n\n"); fprintf($fileshipped, "\n Item QTY\n\n"); } function prepBoFile(&$fileBo) { $fileBo = fopen ("backorder.txt",'w') or die ("no file created"); fprintf($fileBo, "\n BACKORDER REPORT\n\n"); fprintf($fileBo, "\n Item QTY\n\n"); } function doCalcs(&$qtyRequested,$qtyOnHand,$qtyShipped,$qtyBO,$message) { if($qtyRequested <= $qtyOnHand) { $qtyBO = $qtyBO++; } else { $qtyShipped= $qtyShipped++; } } function writeReports($fileshipped,$fileBo,$itemID,&$qtyShipped,&$qtyBO) { if($qtyShipped == $qtyShipped) { fprintf($fileshipped,"\n\nTOTAL SHIPPED %d", $qtyShipped); } else { fprintf($fileBo,"\n\nTOTAL Backordered %d", $qtyBO); } } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.