/* Barcode scanning program. Stage 1: Complete Get the damn thing working. Scan barcodes and be able to edit, add, and discard items. Preliminary support for parent/children. Full database in place, although not all fields are yet being used. Inventory list available via the web. Non production phase. Stage 2: Production phase. Get the database setup finalized so no further projected fields will be needed in the future. Have all fields editable. Transaction logs in place. Have inventory list, and various transaction reports available via web. Stage 3: Convienence phase. Full screen edit menu. Obtain product names via the barcode mysql database. Support for dynamic UPC's (ground beef for instance). Cost tracking. Consumption tracking. Automated shopping list creation based upon current consumption rate. Stage 4: Automation phase. Cookbook interface to automatically slate needed items for selected recipies and cross referencing current inventory to create a new shopping list. Weekly meal planning, both selective and automatic. Automated grocery ordering via groceryworks.com or the like. Categories are groups of products that can effectively replace each other. For instance, I may choose to purchase Dr. Pepper cans or Dr. Pepper in 2/3 litre bottles. In the end, all these products are Dr. Pepper. In addition, I might replace one brand of soap for another. While I may have a soap preference, for the purposes of tracking soap consumption, one bar is pretty much like another. The automated system will decide I need to purchase the equivalent of 24 12 oz cans of Dr. Pepper, but may only have a coupon for the bottles, so it can determine that my best bet for savings will be to purchase the bottles instead. Of course, since the program has no idea what the prices in the store actually are, the consumer can purchase whatever makes sense at the time, but at least he'll have a listing in front of him to work with. If one product is on sale, while the computer recommended another, appropriate changes can be made at the time. TODO: Add field for purchase date, number of days til expiration at time of purchase. */ #include #include #include #include #include #include #include struct trans_type { int number; int mode; //1 - add, 2 - discard float cost; // cost at the time of this transaction. long tm; // Timestamp }; struct recipe_type { char name[80]; // Name of this recipe struct { int number; // Number of this ingredient int category; // Category of this ingredient int units; // Number of units required. }ingredients[30]; char steps[160][20]; // instructions (20 lines) }; struct upc_type { char upc[30]; char name[80]; int quantity; int type; // 1:consumable 2:appliance 3: category float cost; int total_consumed; //how many of these have we discarded. struct //for adjustable rate products { int static_pos; int price_start; int price_end; }specials; int unit; // size of product. char unit_type[15]; // unit measurement (oz,cans, etc) int parent; // parent product (or -1 if none) (-2 if has children) struct { int number; int quantity; }children[10]; int parent_type; // int family; // family code for coupons // int category; // category for this product // int instant; // Is this an instant consumable? }; struct upc_key_element { char upc[30]; int number; }; main() { scanproc(); } int load_upc(struct upc_type *upc, int number) { int x,y,z; int handle; handle = open("barcode.dat",O_RDONLY | O_CREAT); z = lseek(handle,0,2) / sizeof *upc; if(number >= z) { printf("This number is too large.\n"); return(-1); } lseek(handle,number*sizeof *upc,0); read(handle,upc,sizeof *upc); close(handle); } int save_upc(struct upc_type *upc, int number,int mode) { int x,y,z; int handle; handle = open("barcode.dat",O_WRONLY | O_CREAT); z = lseek(handle,0,2) / sizeof *upc; if(mode) // new { lseek(handle,0,2); number=z; } else { if(number >= z) { printf("This number is too large.\n"); return(-1); } lseek(handle,number*sizeof *upc,0); } write(handle,upc,sizeof *upc); close(handle); return(number); } load_keys(struct upc_key_element *keys) { } int find_upc(char upc[30]) { int x,y,z; int handle; struct upc_type upcdata; handle = open("barcode.dat",O_RDONLY | O_CREAT); z = lseek(handle,0,2) / sizeof upcdata; close(handle); for(x=0;x