<?php
	/*
	** File: add_department
	** Description: form for creating a department
	** Version: $Revision: 1.16 $
	** Created: 04/08/1999
	** Author: Leon Atkinson, Shannon -jj Behrens
	** Email: leon@clearink.com, jj@clearink.com
	** CVS Author: $Author: leon $
	** Last Revised: $Date: 1999/12/07 21:45:04 $
	** Log : $Log: add_department,v $
	** Log : Revision 1.16  1999/12/07 21:45:04  leon
	** Log : All forms should be using StartForm now...
	** Log :
	** Log : Revision 1.15  1999/11/08 22:32:19  leon
	** Log : Added prepareText() function to use everywhere we were using htmlentities.
	** Log :
	** Log : Revision 1.14  1999/11/04 21:35:36  leon
	** Log : Cleaned up the use of paths.  Paths are now all set in index.php3 as
	** Log : constants.  Example settings for Apache/Unix, Apache/Win32, and IIS.
	** Log :
	** Log : Revision 1.13  1999/10/12 23:14:45  leon
	** Log : Moved localization constants into 'english' module.  Added constant to
	** Log : control whether unregistered shoppers may checkout.
	** Log :
	** Log : Revision 1.12  1999/10/12 00:39:05  chris
	** Log : Moving text into constants in preparation of localization support.
	** Log :
	** Log : Revision 1.10  1999/09/23 23:46:38  jj
	** Log : Set up the GUI so that admins may not choose multiple department parents, however items may be in multiple departments.
	** Log :
	** Log : Revision 1.9  1999/08/18 22:32:10  leon
	** Log : Returning opening PHP tag to XML-friendly tag
	** Log :
	** Log : Revision 1.8  1999/08/03 22:50:57  jj
	** Log : Doing quality control on department and items editors.
	** Log :
	** Log : Revision 1.7  1999/08/03 00:26:39  jj
	** Log : A large amount of programming changing the whole department and item admin process.
	** Log :
	** Log : Revision 1.6  1999/07/30 17:51:44  jj
	** Log : Streamlined edit_users (cut out one query); other minor fixes.
	** Log :
	** Log : Revision 1.5  1999/07/28 19:27:28  leon
	** Log : Mass update based on code donation from a live project
	** Log :
	** Copyright (c) 1999 Working Dogs.  All rights reserved.
	**
	** Input: possibly $department
	*/

	/* Needed for function DepartmentSelector. */
	include(APPLICATION_ROOT . "/modules/include/department_selector");

	/* Initialize $department (the parent of this created department). */
	$department = isset($department) ? intval($department) : -1;



	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main
	
	
	
	/* Make sure the user has admin rights. */
	if( !$UserInfo["Permission"]["Administrate"] )
	{
		print(L_ADDDEPARTMENT_DENIED . "<BR>\n");
	}
	else
	{
		/* Give this entire screen a nice border. */
		print("<TABLE BORDER=\"1\" WIDTH=\"100%\"><TR><TD>\n");
		print("<B>" . L_ADDDEPARTMENT_ADDINGNEW . "</B><BR>\n");
		
		/* Start the form, and the sub-table. */
		print(StartForm("admin_departments", 'post', 'ADD_DEPARTMENT', FALSE));

		print("<TABLE>\n");
		
		/* Output all of the form entities. */
		print("<TR><TD>" . L_ADDDEPARTMENT_NAME . "</TD>\n");
		print("<TD><INPUT TYPE=\"text\" NAME=\"inputName\" SIZE=\"32\" " .
			"VALUE=\"");
		print(isset($inputName) ? prepareText($inputName) : "");
		print("\"></TD></TR>\n");

		print("<TR><TD>" . L_ADDDEPARTMENT_PARENT . "</TD>\n<TD>");
		DepartmentSelector("inputParent", $department, FALSE);
		print("</TD></TR>\n");

		print("<TR><TD>" . L_ADDDEPARTMENT_GRAPHIC . "</TD>\n");
		print("<TD><INPUT TYPE=\"text\" NAME=\"inputGraphic\" SIZE=\"32\" " . 
			"VALUE=\"");
		print(isset($inputGraphic) ? prepareText($inputGraphic) : "");
		print("\"></TD></TR>\n");
			
		print("<TR><TD>" . L_ADDDEPARTMENT_DESCRIPTION . "</TD>\n");
		print("<TD><TEXTAREA NAME=\"inputDescription\" ROWS=\"5\" " . 
			"COLS=\"40\" WRAP=\"soft\">");
		print(isset($inputDescription) ? prepareText($inputDescription) : "");
		print("</TEXTAREA></TD></TR>\n");

		print("<TR><TD>" . L_ADDDEPARTMENT_DISPLAYPRECEDENCE. "</TD>\n");
		print("<TD><INPUT TYPE=\"text\" NAME=\"inputDisplayPrecedence\" " . 
			"SIZE=\"2\" VALUE=\"");
		print(isset($inputDisplayPrecedence) ?
			prepareText($inputDisplayPrecedence) : "");
		print("\"></TD></TR>\n");

		print("<TR><TD>\n");
		print("<INPUT TYPE=\"submit\" VALUE=\"" . L_ADDDEPARTMENT_ADDDEPARTMENT . "\">\n");
		print("<INPUT TYPE=\"reset\" VALUE=\"" . L_ADDDEPARTMENT_RESET . "\"></TD>\n");
		print("<TD ALIGN=\"right\"><A HREF=\"" . ScreenURL("admin_departments"). 
			"&department=" . intval($department) . 
			"\">" . L_ADDDEPARTMENT_CANCEL . "</A></TD></TR>\n");
		
		/* Finish the form and the sub-table. */
		print("</TABLE>\n");
		print("</FORM>\n");
		
		/* Finish the overall border table. */
		print("</TD></TR></TABLE>\n");
	}

?>
