FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Alerts -Website Inventory





jasonf90
Hi guys,

im trying to create a product inventory website. which im nearly finished.

Im not to sure if i am posting this on the right group.
I had this idea to have a type of warning system for their product inventory.

I thought that the user can input the quantity of products and a warning quantity, so that if the quantity of the product reaches a cretin point it will display a warning that their inventory is getting low.

Example: Product A quantity amount is 10, and its warning amount is 2. So when Product A quantity gets to 2 and below it will display a warning.

If anyone has any idea if this is possible or even how to do it, it would be much appreciated

thanks
jmraker
This is assuming the quantity warning is in the form of an email.

You'd probably want to handle the notification as a report that is run once a day at night in a cron job

While developing the program you'd output the report to a string variable using something like
Code:
$output .= '<li>' . $productName . ' is at ' . (int)$quantity . ' quantity</li>';
instead of
Code:
echo $output .= '<li>' . $productName . ' is at ' . (int)$quantity . ' quantity</li>';

and at the very end echo the string

When the report development is done you setup the cron job and then simply comment out the echo and replace it with a call to mail() and setting the mime type to HTML
Code:
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

// Mail it
mail($to, $subject, $output, $headers);

Set $to to your email address.
You can send it to one or more email addresses later, separate addresses with a comma.

If you want the email to be simple plain text you can forgo the html tags and develop with a
Code:
header('Content-type: text/plain');

or wrap a '<pre>' tag around the echoed string
Code:
echo '<pre>' . $output . '</pre>';


When the program is run from a cron job it could be running as a different user than it would with the webserver so file user permissions could be an issue, the current directory would most likely be different, and the $_SERVER array will be different.

--
The program would probably just need to loop through the results of a query that would be like
Code:
SELECT * FROM product WHERE qtyOnHand<=qtyWarning


If you can't get get it into a query you could select everything and have the program figure out if it's part of the report.
Related topics
Most original website contest
Do you use css to design a website?
Website Dont Work?
Website Templates
Illegal website and illegal downloads!
Security website
Brett Tabke's website tutorial
Is it possible to upload music files to a website?
a photo for my website
best flash template website..?????!?
how to add google ads into my website?
Tutorial website
Site Advertisement and How to get more traffic
Website Design India
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.