public void fulfillOrder()
	{

		try
		{
			PreparedStatement stmt = connection.prepareStatement("select sum(i.price * c.amount * d.percent) as total " +
					" from martitem i " +
					"join cartitem c on i.stock_number = c.stock_number " +
					"join discount d on d.status = ? " +
					"where trim(c.cid) = ? ");
			stmt.setString(1, currentModel.getStatus());
			stmt.setString(2, customerIdentifier);
			ResultSet cartresult = stmt.executeQuery();
			cartresult.next();
			double total = cartresult.getDouble("total");
			if (total <= 100)
			{
				stmt = connection.prepareStatement("select percent from discount where status = 'Shipping'");
				ResultSet srs = stmt.executeQuery();
				srs.next();
				total *= srs.getDouble("percent");
			}
			SaleModel saleModel = new SaleModel(connection);
			int ordnum = getNextOrderId();
			Calendar cal = Calendar.getInstance();
			saleModel.setAll(ordnum, customerIdentifier, total, new Timestamp(new Date().getTime()), cal.get(Calendar.MONTH), cal.get(Calendar.YEAR));
			saleModel.insert();
			cartresult = getCartItems();
			OrderedItemModel orderModel = new OrderedItemModel(connection);
			while (cartresult.next())
			{
				PreparedStatement pstmt = connection.prepareStatement("select (price * ?) as total from martitem where stock_number = ?");
				pstmt.setInt(1, cartresult.getInt("amount"));

				pstmt.setString(2, cartresult.getString("stock_number"));
				ResultSet prs = pstmt.executeQuery();
				prs.next();

				orderModel.setAll(ordnum, cartresult.getString("stock_number"), prs.getDouble("total"), cartresult.getInt("amount"));
				orderModel.insert();
			}
			clearCart();
			
			checkStatus();
			WarehouseController wcon = new WarehouseController(connection);
			wcon.fillCustomerOrder(ordnum);
		} catch (SQLException e)
		{
			e.printStackTrace();
		}
	}