/* Author: Ram Samudrala (me@ram.org)
 * Version: O1.0
 * Detail: <http://www.ram.org/computing/sc/sc.html>
 * November 30, 1996; Copyright (c) 1995 by Ram Samudrala.
 *
 * See the URL above for terms of use and general help.
 */

#include "cgi_common.h"
#include "cgi_defines.h"
#include "sc_defines.h"
#include "items.h"

/******************************************************************/

void display_item_list(item items[])
{
  int i;
  char item_string[20];

  printf("<table border>\n");
  printf("<tr> <th>  </th> <th> Item </th> <th> Quantity </th> <th> Price </th> </tr>\n");
  for(i = 1; i <= total_items(&items); i++)
    {
      if (item_ql(&items[i]) == item_qh(&items[i]))
        sprintf(item_string, "%d", item_ql(&items[i]));
      else
        if (item_qh(&items[i]) == MAX_QUANTITY_PER_ITEM)
          sprintf(item_string, "%d+", item_ql(&items[i]));
        else
          sprintf(item_string, "%d-%d", item_ql(&items[i]), item_qh(&items[i]));

      printf("<tr align=center> <td> <input name=\"%s\" size=\"%s\"> </td> <td> %s </td> <td> %s </td> <td> $%7.2f each </td> </tr>\n",
             item_name(&items[i]), DEFAULT_INPUT_FIELD_SIZE,
	     item_description(&items[i]), item_string,
             item_price(&items[i]));
    }
  printf("</table>");
  return;
}

/******************************************************************/

