Jump to content

My first program and i am lost!


ijustdidit2011

Recommended Posts

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);

        }

    }

 

 

 

 

 

 

 

 

 

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.