/* Author: Ram Samudrala (me@ram.org)
* Version: O1.0
* Detail: \n");
for(i = 0; i <= number_of_entries; i++)
if (entries[i].val[0] != '\0')
{
if (get_item_desc_price(entries[i].name, atoi(entries[i].val), &price, &shipping_price, desc, items))
{
printf(" \n",
desc, atoi(entries[i].val), price, shipping_price);
total_price += price;
total_shipping_price += shipping_price;
}
else
{
if (entries[i].name[0] != 'X')
printf("%s: %s %s %d $%5.2f + shipping ($%5.2f)
\n",entries[i].name, entries[i].val);
else
{
if (strcmp(entries[i].val, "start_table") == 0)
{
printf("
| Item | Quantity | Price |
|---|
\n"); } } } if (international_order) total_shipping_price += INTERNATIONAL_SHIPPING_ADDON; printf("
\n"); printf("The cost of your order is $%5.2f, with\n", total_price); printf("a shipping and handling charge of $%5.2f.\n
\n", total_shipping_price); printf("Total: $%5.2f
\n", total_price + total_shipping_price); return TRUE; } /******************************************************************/ int mail_order(int number_of_entries, int international_order, entry entries[], item items[]) { char buf[1000], file_name[1000], desc[ITEM_DESCRIPTION_STRING_LENGTH]; FILE *output_fp; int i; double price = 0.0, total_price = 0.0, shipping_price = 0.0, total_shipping_price = 0.0; sprintf(buf, ".%d", (int) getpid()); strcpy(file_name, TMP_FILENAME_STRING); strcat(file_name, buf); open_file(&output_fp, file_name, "w", "mail_order"); fprintf(output_fp, "Subject: %s order\n\n", ORGANISATION); for(i = 0; i <= number_of_entries; i++) if (entries[i].val[0] != '\0') { if (get_item_desc_price(entries[i].name, atoi(entries[i].val), &price, &shipping_price, desc, items)) { fprintf(output_fp, "$%5.2f + shipping ($%5.2f) for %2d %s\n", price, shipping_price, atoi(entries[i].val), desc); total_price += price; total_shipping_price += shipping_price; } else { if (entries[i].name[0] != 'X') fprintf(output_fp, "%s: %s\n",entries[i].name, entries[i].val); else { if (strcmp(entries[i].val, "start_table") == 0) fprintf(output_fp, "\n"); if (strcmp(entries[i].val, "end_table") == 0) fprintf(output_fp, "\n"); } } } if (international_order) total_shipping_price += INTERNATIONAL_SHIPPING_ADDON; fprintf(output_fp, "\n\nThe cost of the order is $%5.2f, with a shipping price of $%5.2f.\n", total_price, total_shipping_price); fprintf(output_fp, "\n\n-------------------------------------------------\n"); fprintf(output_fp, "TOTAL PAYMENT DUE (please pay promptly): $%5.2f\n", total_price + total_shipping_price); fprintf(output_fp, "-------------------------------------------------\n"); fprintf(output_fp, "\n\nPlease send payment to:\n"); fprintf(output_fp, "Ram Samudrala\n10418 Marine View Drive\nMukilteo WA 98275\n"); close_file(&output_fp, file_name, "mail_order"); sprintf(buf, "%s %s <%s", SENDMAIL_LOCATION, CARETAKER, file_name); system(buf); /* remove(file_name); */ return TRUE; } /******************************************************************/ int display_order_results_intro(int test_order) { if (test_order) { printf("The items you ordered are listed below along with the cost.\n"); printf("If are certain of your order and wish it to be mailed to %s,\n", ORGANISATION); printf("please use the \"back\" button in your browser and place the order.\n"); printf("You can also change your order in this manner.
\n"); printf("You will receive an e-mail confirming your order within 48 hours. Thank you!
\n"); printf("Please send payment to:
\n"); printf("\nRam Samudrala\n");
printf("10418 Marine View Drive\n");
printf("Mukilteo, WA 98275\n\n");
}
display_signature(SIGNATURE_FILE);
return TRUE;
}
/******************************************************************/