#!/usr/bin/python
# -*- coding: UTF-8 -*-

"""
	addshelter - Add new shelters to the database.
	This file is covered by the GNU GPL v2
"""

import db
import sys

print "Create new shelter..."

# Gather info
code = raw_input("Enter the new shelter's code [leave empty to quit]: ")
if code == "":
	print "Abandoned."
	sys.exit(0)

password = raw_input("Enter the new shelter's password: ")
if password == "":
	print "Abandoned."
	sys.exit(0)

name = raw_input("Enter the new shelter's name: ")
if name == "":
	print "Abandoned."
	sys.exit(0)

address = raw_input("Enter the new shelter's address: ")
if address == "":
	print "Abandoned."
	sys.exit(0)

phone = raw_input("Enter the new shelter's phone number: ")
if phone == "":
	print "Abandoned."
	sys.exit(0)

email = raw_input("Enter the new shelter's email address: ")
if email == "":
	print "Abandoned."
	sys.exit(0)
	
website = raw_input("Enter the new shelter's website URL: ")
if website == "":
	print "Abandoned."
	sys.exit(0)

areas = raw_input("Enter the related area keywords (postcodes, counties, towns, etc): ")
if areas == "":
	print "Abandoned."
	sys.exit(0)

# Write an insert query
sql = "INSERT INTO SHELTER (ID, PASSWORD, NAME, ADDRESS, PHONE, EMAIL, WEBSITE, RELATEDAREAS) VALUES ('" + code + "', '" + password + "', '" + name + "', '" + address + "', '" + phone + "', '" + email + "', '" + website + "', '" + areas + "')"

# Send it to the database
db.executeQuery(sql);
print "Created."
