#include <queue>
#include <string>

using namespace std;

class customer;	// movies need to know that there is a such thing as customers
class forest; 

const int NUM_SORT_FIELDS=8;
enum SORT_FIELDS
{
	SORT_FIELD_TITLE,
	SORT_FIELD_GENRE,
	SORT_FIELD_STOCK,
	SORT_FIELD_RENTALS,
	SORT_FIELD_WAITLISTCOUNT,
	SORT_FIELD_DATEADDED,
	SORT_FIELD_DATERELEASED,
	SORT_FIELD_ID
};
const string SORT_FIELD_NAME[]=
{
	"Title",
	"Genre",
	"Copies in Stock",
	"Number of Rentals",
	"Wait List Size",
	"Date Added",
	"Date Released",
	"ID Number"
};

class movie
{
	public:
	movie(string setIDNum="");
	~movie();
	int checkout(customer *, bool silent=false);
	string checkin(int copyNum);
	bool initNewMovie();
	void load(ifstream &);
	void save(ofstream &);	
	int getStock();
	void displayList(int secondField=SORT_FIELD_GENRE);
	void displayFull(customer *, bool managerAccess=false);
	string getTitle() { return title; }
	int getQueuePosition(string DLN);
	int getWaitlistSize();
	string getID() { return id; }

	void setTitle(string newTitle) { title=newTitle; }
	
	static void setSortField(int fieldNum) { sortField=fieldNum; }
	static void setForestPointer(forest *f) { forestPTR=f; }

	bool operator >  (movie &right);
	bool operator == (movie &right);

	private:
	string id;
	static int sortField;
	static forest* forestPTR;

	string genre;
	string title;
	string rated;
	int rentals;	// total times this movie has been rented in it's life (not the number of copies currently rented out)
	
	time_t dateAdded;
	time_t dateReleased;
	queue<string> waitlist; // holds customer ID numbers
	void serveWaitlist();
	void addNotification(string name, string phone, string dln, int copyNum);
	void displayWaitlist();
	void displayCheckoutList();
	void displayCustomerList(vector<string> customerList, string header="");

	/* for each copy of the movie a status will be kept in the following vector
	   if the status is empty ("") then that copy is in stock.
	   if a status is not empty ("some id") then the customer with that ID has that copy checked out
	*/
	int numCopies;
	vector<string> copyStatus;	// list of customers who currently have this movie checked out
	int getAvailableCopy();	// returns the index of the first available copy to checkout
	void increaseRentals();
	void adjustWaitlistCount();

	string makeIDnum();
};

