<?PHP
include "../inc/var.php";
include "../inc/connect.php";
include $server_inc."/whm_functions.php";
include $server_inc."/client_functions.php";
include $server_inc."/login_functions.php";

// Start Form Handler

if (isset($submit))
	{
	if (strlen(trim($package_name))==0) { $err0=true; } else { $n0=true; }
	if (strlen(trim($monthly_cost))==0) { $err1=true; } else { $n1=true; }
	if (strlen(trim($quarterly_cost))==0) { $err2=true; } else { $n2=true; }
	if (strlen(trim($semi_annual_cost))==0) { $err3=true; } else { $n3=true; }
	if (strlen(trim($annual_cost))==0) { $err4=true; } else { $n4=true; }
	if (strlen(trim($whm_package_name))==0) { $err5=true; } else { $n5=true; }
	if (strlen(trim($web_space))==0) { $err6=true; } else { $n6=true; }
	if (strlen(trim($bandwidth))==0) { $err7=true; } else { $n7=true; }
	if (isset($tpp_high)) { if (strlen(trim($tpp_pro_period))==0) { $err8=true; } else { $n8=true; } } else {$n8=true;}

	if (isset($n0)&&isset($n1)&&isset($n2)&&isset($n3)&&isset($n4)&&isset($n5)&&isset($n7)&&isset($n8))
		{
		// if isset($pid) then it's an edit
		if (isset($pid))
			{
			if ($install_status==0) { $whm_id=0; }
			else if ($install_status==1) { $whm_id=-1; }

			// build the query
			$update="update plan_specs set ";
			$update.="package_name='".addslashes(trim($package_name))."', ";
			$update.="whm_package_name='".addslashes(trim($whm_package_name))."', ";
			$update.="plan_status='".addslashes(trim($plan_status))."', ";
			$update.="monthly_cost='".addslashes(str_replace("$", "", trim($monthly_cost)))."', ";
			$update.="quarterly_cost='".addslashes(str_replace("$", "", trim($quarterly_cost)))."', ";
			$update.="semi_annual_cost='".addslashes(str_replace("$", "", trim($semi_annual_cost)))."', ";
			$update.="annual_cost='".addslashes(str_replace("$", "", trim($annual_cost)))."', ";
			$update.="setup_cost='".addslashes(str_replace("$", "", trim($setup_cost)))."', ";
			$update.="web_space='".addslashes(trim($web_space))."', ";
			$update.="shell_access='".addslashes(trim($shell_access))."', ";
			$update.="ftp='".addslashes(trim($ftp))."', ";
			$update.="email='".addslashes(trim($email))."', ";
			$update.="email_list='".addslashes(trim($email_list))."', ";
			$update.="sql='".addslashes(trim($sql))."', ";
			$update.="sub_domain='".addslashes(trim($sub_domain))."', ";
			$update.="parked_domain='".addslashes(trim($parked_domain))."', ";
			$update.="addon_domain='".addslashes(trim($addon_domain))."', ";
			$update.="cgi_access='".addslashes(trim($cgi_access))."', ";
			$update.="frontpage='".addslashes(trim($frontpage))."', ";
			$update.="bandwidth='".addslashes(trim($bandwidth))."', ";
			$update.="cpanel_theme='".addslashes(trim($cpanel_theme))."', ";
			$update.="monthly_pid='".addslashes(trim($monthly_pid))."', ";
			$update.="quarterly_pid='".addslashes(trim($quarterly_pid))."', ";
			$update.="semi_annual_pid='".addslashes(trim($semi_annual_pid))."', ";
			$update.="annual_pid='".addslashes(trim($annual_pid))."', ";
			$update.="whm_id='".addslashes(trim($whm_id))."', ";
			$update.="addon_gid='".addslashes(trim($addon_gid))."', ";
			$update.="rid='".addslashes(trim($rid))."', ";
			$update.="display_text='".addslashes(trim($display_text))."', ";
			if (isset($free_trial)) 
				{
				$update.="free_trial='1', ";
				$update.="free_trial_length='".addslashes(trim($free_trial_length))."', ";
				}
			else 
				{ 
				$update.="free_trial='0', ";
				$update.="free_trial_length='0', ";
				}

			if (isset($tpp_pro_period))
				{
				$update.="tpp_pro_period='".addslashes(trim($tpp_pro_period))."', ";
				}
			else
				{
				$update.="tpp_pro_period='x', ";
				}
			$update.="gid='".addslashes(trim($gid))."' ";
			$update.="where pid='".addslashes(trim($pid))."'";

			// execute the query
			mysql_query($update);
			
			if ($addon_gid!=0)
				{
				// update the payment processors for the group
				mysql_query("update addon_groups set group_payment='' where addon_gid='".addslashes(trim($addon_gid))."'");
				}
			}
		else
			{
			if ($install_status==0) { $whm_id=0; }
			else if ($install_status==1) { $whm_id=-1; }
			// build the query
			$add="insert into plan_specs set ";
			$add.="package_name='".addslashes(trim($package_name))."', ";
			$add.="whm_package_name='".addslashes(trim($whm_package_name))."', ";
			$add.="plan_status='".addslashes(trim($plan_status))."', ";
			$add.="monthly_cost='".addslashes(str_replace("$", "", trim($monthly_cost)))."', ";
			$add.="quarterly_cost='".addslashes(str_replace("$", "", trim($quarterly_cost)))."', ";
			$add.="semi_annual_cost='".addslashes(str_replace("$", "", trim($semi_annual_cost)))."', ";
			$add.="annual_cost='".addslashes(str_replace("$", "", trim($annual_cost)))."', ";
			$add.="setup_cost='".addslashes(str_replace("$", "", trim($setup_cost)))."', ";
			$add.="web_space='".addslashes(trim($web_space))."', ";
			$add.="shell_access='".addslashes(trim($shell_access))."', ";
			$add.="ftp='".addslashes(trim($ftp))."', ";
			$add.="email='".addslashes(trim($email))."', ";
			$add.="email_list='".addslashes(trim($email_list))."', ";
			$add.="sql='".addslashes(trim($sql))."', ";
			$add.="sub_domain='".addslashes(trim($sub_domain))."', ";
			$add.="parked_domain='".addslashes(trim($parked_domain))."', ";
			$add.="addon_domain='".addslashes(trim($addon_domain))."', ";
			$add.="cgi_access='".addslashes(trim($cgi_access))."', ";
			$add.="frontpage='".addslashes(trim($frontpage))."', ";
			$add.="bandwidth='".addslashes(trim($bandwidth))."', ";
			$add.="cpanel_theme='".addslashes(trim($cpanel_theme))."', ";
			$add.="monthly_pid='".addslashes(trim($monthly_pid))."', ";
			$add.="quarterly_pid='".addslashes(trim($quarterly_pid))."', ";
			$add.="semi_annual_pid='".addslashes(trim($semi_annual_pid))."', ";
			$add.="annual_pid='".addslashes(trim($annual_pid))."', ";
			$add.="whm_id='".addslashes(trim($whm_id))."', ";
			$add.="addon_gid='".addslashes(trim($addon_gid))."', ";
			$add.="rid='".addslashes(trim($rid))."', ";
			if (isset($free_trial)) 
				{
				$add.="free_trial='1', ";
				$add.="free_trial_length='".addslashes(trim($free_trial_length))."', ";
				}
			else 
				{ 
				$add.="free_trial='0', ";
				$add.="free_trial_length='0', ";
				}
			if (isset($tpp_pro_period))
				{
				$add.="tpp_pro_period='".addslashes(trim($tpp_pro_period))."', ";
				}
			else
				{
				$add.="tpp_pro_period='x', ";
				}
			$add.="gid='".addslashes(trim($gid))."' ";

			// execute the query
			mysql_query($add);

			// get the last entry id, call it PID
			$pid=mysql_insert_id();
			
			if ($addon_gid!=0)
				{
				// update the payment processors for the group
				mysql_query("update addon_groups set group_payment='' where addon_gid='".addslashes(trim($addon_gid))."'");
				}
			}
		$done=true;
		}
	}

// End Form Handler

include $server_admin_inc."/header.php";

if (isset($pid))
	{
	$query="select ";
	$query.="package_name, ";		// 0
	$query.="whm_package_name, ";	// 1
	$query.="plan_status, ";		// 2
	$query.="monthly_cost, ";		// 3
	$query.="quarterly_cost, ";		// 4
	$query.="semi_annual_cost, ";	// 5
	$query.="annual_cost, ";		// 6
	$query.="setup_cost, ";			// 7
	$query.="web_space, ";			// 8
	$query.="shell_access, ";		// 9
	$query.="ftp, ";				// 10
	$query.="email, ";				// 11
	$query.="email_list, ";			// 12
	$query.="sql, ";				// 13
	$query.="sub_domain, ";			// 14
	$query.="parked_domain, ";		// 15
	$query.="addon_domain, ";		// 16
	$query.="cgi_access, ";			// 17
	$query.="frontpage, ";			// 18
	$query.="bandwidth, ";			// 19
	$query.="cpanel_theme, ";		// 20
	$query.="tpp_pro_period, ";		// 21
	$query.="gid, ";				// 22
	$query.="monthly_pid, ";		// 23
	$query.="quarterly_pid, ";		// 24
	$query.="semi_annual_pid, ";	// 25
	$query.="annual_pid, ";			// 26
	$query.="whm_id, ";				// 27
	$query.="addon_gid, ";			// 28
	$query.="free_trial, ";			// 29
	$query.="free_trial_length, ";	// 30
	$query.="rid, ";				// 31
	$query.="display_text ";		// 32
	$query.="from plan_specs ";
	$query.="where pid='".addslashes(trim($pid))."'";

	// execute query
	$rs=mysql_fetch_row(mysql_query($query));

	$package_name=stripslashes(trim($rs[0]));
	$whm_package_name=stripslashes(trim($rs[1]));
	$plan_status=stripslashes(trim($rs[2]));
	$monthly_cost=stripslashes(trim($rs[3]));
	$quarterly_cost=stripslashes(trim($rs[4]));
	$semi_annual_cost=stripslashes(trim($rs[5]));
	$annual_cost=stripslashes(trim($rs[6]));
	$setup_cost=stripslashes(trim($rs[7]));
	$web_space=stripslashes(trim($rs[8]));
	$shell_access=stripslashes(trim($rs[9]));
	$ftp=stripslashes(trim($rs[10]));
	$email=stripslashes(trim($rs[11]));
	$email_list=stripslashes(trim($rs[12]));
	$sql=stripslashes(trim($rs[13]));
	$sub_domain=stripslashes(trim($rs[14]));
	$parked_domain=stripslashes(trim($rs[15]));
	$addon_domain=stripslashes(trim($rs[16]));
	$cgi_access=stripslashes(trim($rs[17]));
	$frontpage=stripslashes(trim($rs[18]));
	$bandwidth=stripslashes(trim($rs[19]));
	$cpanel_theme=stripslashes(trim($rs[20]));
	$tpp_pro_period=stripslashes(trim($rs[21]));
	$gid=stripslashes(trim($rs[22]));
	$monthly_pid=stripslashes(trim($rs[23]));
	$quarterly_pid=stripslashes(trim($rs[24]));
	$semi_annual_pid=stripslashes(trim($rs[25]));
	$annual_pid=stripslashes(trim($rs[26]));
	$whm_id=stripslashes(trim($rs[27]));
	$addon_gid=stripslashes(trim($rs[28]));
	$free_trial=stripslashes(trim($rs[29]));
	$free_trial_length=stripslashes(trim($rs[30]));
	$rid=stripslashes(trim($rs[31]));
	$display_text=stripslashes(trim($rs[32]));

	if ($whm_id==0)
		{
		$install_status=0;
		}
	else if ($whm_id==-1)
		{
		$install_status=1;
		}
	else
		{
		$install_status=2;
		}
	}
else
	{
	$install_status=0;
	}

# added 6/16/2003 - is paypal active?
$query_x="select ";
$query_x.="status "; // 0
$query_x.="from ";
$query_x.="payment_process ";
$query_x.="where ";
$query_x.="pid='1'";

$rs_x=mysql_fetch_row(mysql_query($query_x));

$show_status=stripslashes(trim($rs_x[0]));
# end added 6/16/2003

// Check to make sure we have groups defined
$ct=mysql_fetch_row(mysql_query("select count(*) from plan_groups"));

// start error messages table
if (isset($err0)||isset($err1)||isset($err2)||isset($err3)||isset($err4)||isset($err5)||isset($err6)||isset($err7)||isset($err8))
	{
	echo"<table width='100%' cellpadding='2' cellspacing='0' border='0'>";
	}

// Left MIB Package null
if (isset($err0))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter a <b>MIB Package Name</b> to continue.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// No Monthly price defined
if (isset($err1))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter a <b>Monthly Cost</b> to continue.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// No Quarterly price defined
if (isset($err2))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter a <b>Quarterly Cost</b> to continue.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// No Semi-Annual price defined
if (isset($err3))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter a <b>Semi-Annual</b> Cost to continue.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// No Annual price defined
if (isset($err4))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter a <b>Annual Cost</b> to continue.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// No Web Host Manager Plan Name defined.
if (isset($err5))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter a <b>WHM plan name</b> to continue.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// No web space amount defined.
if (isset($err6))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter an amount of <b>web space</b> to continue.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// No bandwidth amount defined.
if (isset($err7))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter an amount of <b>bandwidth</b> to continue.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// Missing TPP-PRO Period
if (isset($err8))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter a <b>TPP-PRO Period</b> to continue.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// complete the error table
if (isset($err0)||isset($err1)||isset($err2)||isset($err3)||isset($err4)||isset($err5)||isset($err6)||isset($err7)||isset($err8))
	{
	echo("
			<tr>
				<td align='left' valign='top'><hr align='left' valign='top' color='#F0EFED' width='725'></td>
			</tr>
		</table>
		");
	}

// ok, all done - Plan added
if (isset($done))
	{
	echo("
		<table width='725' cellpadding='2' cellspacing='0' border='0'>
			<tr>
				<td align='left' valign='top'><img src='".$http_images."/menu_arrow.gif'>The plan was ".((isset($pid))?"edited":"created")." successfully!</td>
			</tr>
			<tr>
				<td align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><a href='".$http_admin."/plan_build.php?sid=".trim($sid)."'>Add a new package</a>.</td>
			</tr>
			<tr>
				<td align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><a href='".$http_admin."/plan_edit.php?sid=".trim($sid)."'>Choose a package to edit</a>.</td>
			</tr>
			<tr>
				<td align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Make edits to <b>".$package_name."</b> below:</td>
			</tr>
			<tr>
				<td align='left' valign='top'><hr align='left' valign='top' color='#F0EFED' width='725'></td>
			</tr>
		</table>
		");
	}

// if we have no groups defined kill off script until we can get some added.
if ($ct[0]<=0)
	{
	echo("
		<table width='725' border='0' cellspacing='1' cellpadding='2'>
			<tr>
				<td align='left' valign='top'><img src='".$http_images."/error_arrow.gif'><b>No plan groups defined.</b></td> 
			</tr>
			<tr>
				<td align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
			<tr>
				<td align='left' valign='top'>Please use the <a href='".$http_admin."/group_editor.php?sid=".$sid."'>Group Editor</a> to define a plan group.</td> 
			</tr>
		</table>
			");
		// End Main Process
		mysql_close($dblink);
		die();
		}

echo("
<form action='".$PHP_SELF."' method='POST'>
".((isset($pid))?"<input type='hidden' name='pid' value='".trim($pid)."'>":"")."
<input type='hidden' name='sid' value='".trim($sid)."'>
<table width='725' cellpadding='2' cellspacing='0' border='0'>
	<tr>
		<td colspan='2' align='left' valign='top'><img src='".$http_images."/menu_arrow.gif'><b>MIB Details</b></td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err0))?"error_arrow.gif":"space.gif")."' width='15' height='9'>Package Name:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='30' maxlength='255' name='package_name' value='".((isset($pid))?"".stripslashes($package_name)."":"".((isset($package_name))?"".trim(stripslashes($package_name))."":"")."")."'> [Required]</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Plan Status:</td> 
		<td width='75%' align='left' valign='top'><input type='checkbox' name='plan_status' VALUE='1'".((isset($pid))?"".(($plan_status==1)?" checked":"")."":" checked")."> Check to make package viewable to the public.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Choose Plan Group:</td> 
		<td width='75%' align='left' valign='top'>
		<select name='gid' ".$input_style.">
	");
$rog=mysql_query("select gid, name from plan_groups order by name asc");
while ($rg=mysql_fetch_row($rog))
	{
	echo"<option value='".$rg[0]."'".((isset($pid))?"".(($rg[0]==$gid)?" selected":"")."":"".((isset($gid))?"".(($gid==$rg[0])?" selected":"")."":"")."").">".stripslashes($rg[1])."</option>\n";
	}
echo("
		</select>
		</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Choose a Reseller Profile:</td> 
		<td width='75%' align='left' valign='top'>
		<select name='rid' ".$input_style.">
			<option value='0'".((isset($rid))?"".(($rid==0)?" selected":"")."":" selected").">This is not a reseller package</option>
	");
$roh=mysql_query("select rid, profile_name from reseller_profile order by profile_name asc");
while ($rh=mysql_fetch_row($roh))
	{
	echo"<option value='".$rh[0]."'".((isset($rid))?"".(($rid==$rh[0])?" selected":"")."":"").">".stripslashes($rh[1])."</option>\n";
	}
echo("
		</select>
		</td> 
	</tr>
	");
if ($gid==0)
	{
	echo("
		<tr>
			<td width='25%' align='left' valign='top'></td> 
			<td width='75%' align='left' valign='top'><img src='".$http_images."/drop_arrow.gif' width='15' height='9'>No defined group for this package. Please choose a group and update this form.</td> 
		</tr>
		");
	}
echo("
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Choose Addon Group:</td> 
		<td width='75%' align='left' valign='top'>
		<select name='addon_gid' ".$input_style.">
			<option value='0'>Show No Addons</option>
	");
$rogx=mysql_query("select addon_gid, name from addon_groups where group_status='1' order by name asc");
while ($rgx=mysql_fetch_row($rogx))
	{
	echo"<option value='".$rgx[0]."'";
	if (isset($pid)) { if ($addon_gid==$rgx[0]) { echo " selected"; } }
	echo">".stripslashes($rgx[1])."</option>\n";
	}
echo("
		</select>
		</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Order Install Instructions:</td> 
		<td width='75%' align='left' valign='top'><input type='radio' name='install_status' value='0'".(($install_status==0)?" checked":"")."> Use defaults defined in the <a href='".$http_admin."/server_edit.php?sid=".$sid."'>Server Config Menu</a>.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'></td> 
		<td width='75%' align='left' valign='top'><input type='radio' name='install_status' value='1'".(($install_status==1)?" checked":"")."> Manually Install orders for this Package.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'></td> 
		<td width='75%' align='left' valign='top'><input type='radio' name='install_status' value='2'".(($install_status==2)?" checked":"")."> 
		<select name='whm_id' ".$input_style.">
	");
$csRow=mysql_query("select whm_id, server_name from server_config order by server_name asc");
while ($cs=mysql_fetch_row($csRow))
	{
	echo"<option value='".$cs[0]."'".((isset($pid))?"".(($cs[0]==$whm_id)?" selected":"")."":"".((isset($whm_id))?"".(($whm_id==$cs[0])?" selected":"")."":"")."").">Auto-Install orders for this Package on: ".stripslashes($cs[1])."</option>\n";
	}
echo("
		</select>
		</td> 
	</tr>
	<tr>
		<td colspan='2'><hr align='left' valign='top' color='#F0EFED' width='725'></td>
	</tr>
	<tr>
		<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
	</tr>
	<tr>
		<td colspan='2' align='left' valign='top'><img src='".$http_images."/menu_arrow.gif'><b>Pay Structure</b></td> 
	</tr>
	");
// is TPP PRO Active? if so grab the PaySystems TPP-Pro Period Value
$rs_tpp=mysql_fetch_row(mysql_query("select status from payment_process where name='Paysystems TPP-PRO'"));

// is 2co an option?
$rs_2co=mysql_fetch_row(mysql_query("select status from payment_process where name='2Checkout'"));
if ($rs_tpp[0]==1)
	{
	echo("
		<!--- set bit for error checking--->
		<input type='hidden' name='tpp_high' value='1'>
		<tr>
			<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err8))?"error_arrow.gif":"space.gif")."' width='15' height='9'>PaySystems TPP-Pro Period:</td> 
			<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='tpp_pro_period' value='".((isset($pid))?"".(($tpp_pro_period==0)?"":"".$tpp_pro_period."")."":"".((isset($tpp_pro_period))?"".((trim($tpp_pro_period)=="0")?"":"".trim($tpp_pro_period)."")."":"")."")."'>&nbsp;&nbsp;[Required]</td> 
		</tr>
		");
	}
echo("
	<tr>
		<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='8'></td> 
	</tr>
	");
if ($show_status==1)
	{
	echo("
		<tr>
			<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><b>Paypal Only</b> - Free Trial Period:</td> 
			<td width='75%' align='left' valign='top'><input type='checkbox' name='free_trial' value='1'".((isset($free_trial))?"".(($free_trial==1)?" checked":"")."":"")."> Check here to give a <select name='free_trial_length' ".$input_style.">
		");
	for ($i=1; $i<=30; $i++)
		{
		echo "<option value='".$i."'".((isset($free_trial_length))?"".(($free_trial_length==$i)?" selected":"")."":"").">".$i."</option>\n";
		}
	echo("		
			</select> month free trial.&nbsp;&nbsp;[Optional]</td> 
		</tr>
		<tr>
			<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='8'></td> 
		</tr>
		");
	}
echo("
	<tr>
		<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><font color='#990000'>Enter -1 to <b>not display</b> a payment period in the order system.</font></td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err1))?"error_arrow.gif":"space.gif")."' width='15' height='9'>Monthly Cost:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='monthly_cost' value='".((isset($pid))?"".$monthly_cost."":"".((isset($monthly_cost))?"".trim($monthly_cost)."":"")."")."'>");
if ($rs_2co[0]==1)
	{
	echo"&nbsp;&nbsp;2Checkout ID:&nbsp<input ".$input_style." type='text' size='4' maxlength='32' name='monthly_pid' value='".((isset($monthly_pid))?"".$monthly_pid."":"")."'>";
	}
echo("&nbsp;&nbsp;[Required]</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err2))?"error_arrow.gif":"space.gif")."' width='15' height='9'>Quarterly Cost:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='quarterly_cost' value='".((isset($pid))?"".$quarterly_cost."":"".((isset($quarterly_cost))?"".trim($quarterly_cost)."":"")."")."'>");
if ($rs_2co[0]==1)
	{
	echo"&nbsp;&nbsp;2Checkout ID:&nbsp<input ".$input_style." type='text' size='4' maxlength='32' name='quarterly_pid' value='".((isset($quarterly_pid))?"".$quarterly_pid."":"")."'>";
	}
echo("&nbsp;&nbsp;[Required]</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err3))?"error_arrow.gif":"space.gif")."' width='15' height='9'>Semi-Annual Cost:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='semi_annual_cost' value='".((isset($pid))?"".$semi_annual_cost."":"".((isset($semi_annual_cost))?"".trim($semi_annual_cost)."":"")."")."'>");
if ($rs_2co[0]==1)
	{
	echo"&nbsp;&nbsp;2Checkout ID:&nbsp<input ".$input_style." type='text' size='4' maxlength='32' name='semi_annual_pid' value='".((isset($semi_annual_pid))?"".$semi_annual_pid."":"")."'>";
	}
echo("&nbsp;&nbsp;[Required]</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err4))?"error_arrow.gif":"space.gif")."' width='15' height='9'>Annual Cost:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='annual_cost' value='".((isset($pid))?"".$annual_cost."":"".((isset($annual_cost))?"".trim($annual_cost)."":"")."")."'>");
if ($rs_2co[0]==1)
	{
	echo"&nbsp;&nbsp;2Checkout ID:&nbsp<input ".$input_style." type='text' size='4' maxlength='32' name='annual_pid' value='".((isset($annual_pid))?"".$annual_pid."":"")."'>";
	}
echo("&nbsp;&nbsp;[Required]</td> 
	</tr>
	<tr>
		<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='8'></td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Setup Fee:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='setup_cost' value='".((isset($pid))?"".(($setup_cost==0)?"":"".$setup_cost."")."":"".((isset($setup_cost))?"".trim($setup_cost)."":"")."")."'> [leave blank for no setup fee]".(($rs_2co[0]==1)?"<br><img border='0' src='".$http_images."/space.gif' width='2' height='16'><img src='".$http_images."/drop_arrow.gif'><font color='#990000'>* Setup fee does not apply for 2Checkout.</font><br><img src='".$http_images."/space.gif' width='20' height='16'><font color='#990000'>You can enter a value for your clients to see, but the value must be set at 2checkout to be charged.</font>":"")."</td> 
	</tr>
	<tr>
		<td colspan='2'><hr align='left' valign='top' color='#F0EFED' width='725'></td>
	</tr>
	<tr>
		<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
	</tr>
	<tr>
		<td colspan='2' align='left' valign='top'><img src='".$http_images."/menu_arrow.gif'><b>WHM Details</b></td> 
	</tr>
	");
if ($reseller==1)
	{
	echo("
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err5))?"error_arrow.gif":"space.gif")."' width='15' height='9'>WHM Plan Name:</td> 
		<td width='75%' align='left' valign='top'><select name='whm_package_name' ".$input_style.">
		");
	$packages=list_reseller_plans($rsip[0], $whm_username, $whm_password);
	$tok = strtok($packages,"|");
	while ($tok) 
		{
		$data.="<option value='".str_replace("|","", $packages)."'>".str_replace("|","", $packages)."</option>\n";
		$tok = strtok("|");
		}
	echo $data;
	echo("
	</select></td> 
	</tr>
		");
	}
else
	{
	echo("
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err5))?"error_arrow.gif":"space.gif")."' width='15' height='9'>WHM Plan Name (no spaces):</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='30' maxlength='255' name='whm_package_name' value='".((isset($pid))?"".stripslashes($whm_package_name)."":"".((isset($whm_package_name))?"".trim(stripslashes($whm_package_name))."":"")."")."'> [Required]</td> 
	</tr>
		");
	}
echo("
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err6))?"error_arrow.gif":"space.gif")."' width='15' height='9'>Web Space Quota:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='10' maxlength='10' name='web_space' value='".((isset($pid))?"".$web_space."":"".((isset($web_space))?"".trim($web_space)."":"")."")."'> <b>MB</b> [Required]</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err7))?"error_arrow.gif":"space.gif")."' width='15' height='9'>Bandwidth Limit:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='10' maxlength='20' name='bandwidth' value='".((isset($pid))?"".$bandwidth."":"".((isset($bandwidth))?"".trim($bandwidth)."":"")."")."'> <b>MB</b> [Required]</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Shell Access:</td> 
		<td width='75%' align='left' valign='top'><input type='checkbox' name='shell_access' VALUE='1'".((isset($pid))?"".(($shell_access==1)?" checked":"")."":"".((isset($shell_access))?" checked":"")."")."> Check to grant access.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Cgi Access:</td> 
		<td width='75%' align='left' valign='top'><input type='checkbox' name='cgi_access' VALUE='1'".((isset($pid))?"".(($cgi_access==1)?" checked":"")."":"".((isset($cgi_access))?" checked":"")."")."> Check to grant access.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Frontpage Extentions:</td> 
		<td width='75%' align='left' valign='top'><input type='checkbox' name='frontpage' VALUE='1'".((isset($pid))?"".(($frontpage==1)?" checked":"")."":"".((isset($frontpage))?" checked":"")."")."> Check to grant access.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Max Ftp Accounts:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='ftp' value='".((isset($pid))?"".$ftp."":"".((isset($ftp))?"".trim($ftp)."":"-1")."")."'> Set to -1 for Unlimited.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Max Email Accounts:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='email' value='".((isset($pid))?"".$email."":"".((isset($email))?"".trim($email)."":"-1")."")."'> Set to -1 for Unlimited.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Max Email Lists:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='email_list' value='".((isset($pid))?"".$email_list."":"".((isset($email_list))?"".trim($email_list)."":"-1")."")."'> Set to -1 for Unlimited.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Max SQL Databases:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='sql' value='".((isset($pid))?"".$sql."":"".((isset($sql))?"".trim($sql)."":"-1")."")."'> Set to -1 for Unlimited.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Max Sub Domains:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='sub_domain' value='".((isset($pid))?"".$sub_domain."":"".((isset($sub_domain))?"".trim($sub_domain)."":"-1")."")."'> Set to -1 for Unlimited.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Max Parked Domains:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='parked_domain' value='".((isset($pid))?"".$parked_domain."":"".((isset($parked_domain))?"".trim($parked_domain)."":"0")."")."'> Set to -1 for Unlimited.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Max Addon Domains:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='addon_domain' value='".((isset($pid))?"".$addon_domain."":"".((isset($addon_domain))?"".trim($addon_domain)."":"0")."")."'> Set to -1 for Unlimited.</td> 
	</tr>
	");
if (isset($pid))
	{
	if ($whm_id!=-1&&$whm_id!=0)
		{
		$current_server=current_server($pid, 0);
		}
	else
		{
		$current_server=current_server_internal();
		}
	}
else
	{
	$current_server=current_server_internal();
	}
$current_server_root=current_server_root($current_server);
if ($current_server!=99&&trim($current_server_root)=="0")
	{
	echo("
		<tr>
			<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Cpanel Theme:</td> 
			<td width='75%' align='left' valign='top'>
			<select name='cpanel_theme' ".$input_style.">
		");

	// read in variables to connect to whm
	$temp=@read_log($current_server, $below_public);
	list($whm_username, $whm_password)=split("[|]", $temp);
	
	// get the server IP
	$rsip=mysql_fetch_row(mysql_query("select server_ip from server_config where whm_id='".addslashes(trim($current_server))."'"));

	$xtheme=strtok(list_cpanel_themes($rsip[0], $whm_username, $whm_password),"|");
	while ($xtheme) 
		{
		echo "<option value='".$xtheme."'";
		if (isset($pid))
			{
			if (trim($xtheme)==trim($cpanel_theme))
				{
				echo" selected";
				}
			}
		else if (isset($cpanel_theme))
			{
			if (trim($xtheme)==trim($cpanel_theme))
				{
				echo" selected";
				}
			}
		else
			{
			if (trim($xtheme)=="default")
				{
				echo" selected";
				}
			}
		echo">".$xtheme."</option>\n";
		$xtheme = strtok("|");
		}
	echo("
			</select>
			</td> 
		</tr>
		");
	}
else
	{
	if (trim($default_reseller_cpanel_theme)=="")
		{
		echo"<input type='hidden' name='cpanel_theme' value='Default'>";
		}
	else
		{
		echo"<input type='hidden' name='cpanel_theme' value='".trim($default_reseller_cpanel_theme)."'>";
		}
	}
echo("
	<tr>
		<td colspan='2'><hr align='left' valign='top' color='#F0EFED' width='725'></td>
	</tr>
	<tr>
		<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/menu_arrow.gif'><b>Package Description</b></td> 
		<td width='75%' align='left' valign='top'><font color='#990000'>* This description shows up in step one of the order process.</font></td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Attributes Available:</td> 
		<td width='75%' align='left' valign='top'>
		<table width='470' cellpadding='4' cellspacing='0' border='1' bordercolor='#F0EFED'>
			<tr>
				<td width='50%' align='left' valign='middle'>&nbsp;{{web_space}}</td>
				<td width='50%' align='left' valign='middle'>&nbsp;{{bandwidth}}</td>
			</tr>
			<tr>
				<td width='50%' align='left' valign='middle'>&nbsp;{{shell}}</td>
				<td width='50%' align='left' valign='middle'>&nbsp;{{cgi}}</td>
			</tr>
			<tr>
				<td width='50%' align='left' valign='middle'>&nbsp;{{frontpage}}</td>
				<td width='50%' align='left' valign='middle'>&nbsp;{{ftp}}</td>
			</tr>
			<tr>
				<td width='50%' align='left' valign='middle'>&nbsp;{{ftp}}</td>
				<td width='50%' align='left' valign='middle'>&nbsp;{{email}}</td>
			</tr>
			<tr>
				<td width='50%' align='left' valign='middle'>&nbsp;{{email_list}}</td>
				<td width='50%' align='left' valign='middle'>&nbsp;{{sql}}</td>
			</tr>
			<tr>
				<td width='50%' align='left' valign='middle'>&nbsp;{{sub_domain}}</td>
				<td width='50%' align='left' valign='middle'>&nbsp;{{parked_domain}}</td>
			</tr>
			<tr>
				<td width='50%' align='left' valign='middle'>&nbsp;{{addon_domain}}</td>
				<td width='50%' align='left' valign='middle'>&nbsp;{{cpanel_theme}}</td>
			</tr>
		</table>
		</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Display Text:</td> 
		<td width='75%' align='left' valign='top'><textarea name='display_text' rows='16' cols='75' ".$input_style.">".((isset($display_text))?"".((trim($display_text)!="")?"".htmlentities($display_text)."":"{{web_space}} MB Web Space, {{bandwidth}} MB Transfer, {{email}} Email Addresses")."":"{{web_space}} MB Web Space, {{bandwidth}} MB Transfer, {{email}} Email Addresses")."</textarea></td> 
	</tr>
	<tr>
		<td colspan='2' align='left' valign='top'><hr color='#F0EFED' width='725'></td>
	</tr>
	<tr>
		<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'></td> 
		<td width='75%' align='left' valign='top'><input ".$button_style." type='submit' name='submit' value='".((isset($pid))?"Edit":"Create")." Hosting Package Now &gt'></td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='247' height='1'></td> 
		<td width='75%' align='left' valign='top'><img src='".$http_images."/space.gif' width='277' height='1'></td> 
	</tr>
	<tr>
		<td colspan='2'><img src='".$http_images."/space.gif' width='1' height='8'></td>
	</tr>
</table>
</form>
	");

mysql_close($dblink);
include $server_admin_inc."/footer.php";
?>