__section__
default
__description__
Edit subscription information

* user = The user doing the editing, which may or may not be the
	user being edited (if not, it's an admin).
* user_edit = The user being edited.  Fields used are buypage_*
	and hits_{paidfor,bought,bought_today_max}.
* user_newvalues = Also passed in;  supercedes user_edit where its
	fields are present.
* pages = Arrayref of hashrefs, each hashref having fields:
	pagename = name of the page type to append to "buypage_"
	descr = description to print for page name

__title__

__page__
subscribe
__lang__
en_US
__name__
edit
__template__
<div class="generalbody">
[% IF !user.is_admin; user_edit = user; END %]

	[% IF (constants.subscribe_allow_gifts && (!constants.subscribe_gift_testing || user.is_admin)) %]
		<p>You can buy a subscription for yourself or a gift subscription for another user.
		Payment options include PayPal and credit-card.
		<p>Recipients of gift subscriptions will be notified of your purchase through email.

		[% IF user.is_subscriber %]<p>Want to be notified when your subscription is running low or expires?  Change your notification options <a href="[% gSkin.rootdir %]/my/messages/">here</a> [% END %]
	
		<form method="post" action="[% gSkin.rootdir %]/subscribe.pl">
		<fieldset>
			<legend>Gift Subscriptions</legend>
		<input type="radio" name="subscription_type" value="user"> Buy Pages for [% user.nickname | strip_literal %]
		<input type="radio" name="subscription_type" value="gift"> Buy Gift Subscription for UID <input type="text" name="uid" size="6">

		<br>
			For gift subscriptions only:<br>
			Who do you want the recipient to be told the gift is from?<br>
			<input type="text" name="from" size="15" maxlength="30"> (30 character limit, defaults to your username if nothing is entered)
		<input type="hidden" name="op" value="confirm"><input type="submit" value="Continue and choose payment type">
		</fieldset>
	</form>
	[% ELSE %]
		<p>Hit the PayPal or credit-card link below to subscribe to
		[% constants.sitename %].
		You will be able to purchase banner-ad-free pages.
		
		[% IF user.is_subscriber %]<p>Want to be notified when your subscription is running low or expires?  Change your notification options <a href="[% gSkin.rootdir %]/my/messages/">here</a> [% END %]

		[% PROCESS paypalbut %]
		[% PROCESS ccbut %]
	[% END %]

[%
	pages = [
		{ pagename => "index",
		  descr	   => "<b>Homepage</b> (Plum: see the Mysterious Future!)" },
		{ pagename => "article",
		  descr	   => "<b>Stories</b> (Plum: reading Mysterious Future stories)" },
		{ pagename => "comments",
		  descr	   => "<b>Comments</b>" },
	];
%]

[%
	hits_paidfor          = user_newvalues.hits_paidfor
		|| user_edit.hits_paidfor          || 0;
	hits_bought           = user_newvalues.hits_bought
		|| user_edit.hits_bought           || 0;
	hits_bought_today     = user_newvalues.hits_bought_today
		|| user_edit.hits_bought_today     || 0;
	hits_bought_today_max = user_newvalues.hits_bought_today_max;
	FOREACH page = pages;
		thispagename = "buypage_${page.pagename}";
		IF user_newvalues.$thispagename.defined;
			page.isbought = user_newvalues.$thispagename;
		ELSE;
			page.isbought = user_edit.$thispagename;
		END;
	END;
%]

[% IF user.is_admin || ( hits_paidfor && (hits_paidfor > hits_bought) );
	can_buy = 1; ELSE; can_buy = 0; END %]

<p>[% IF user.uid == user_edit.uid %]You have[% ELSE %]User "[% user_edit.nickname | strip_literal %]" has[% END %]
paid for a total of [% hits_paidfor %] pages
and so far [% hits_bought %] have been used up
([% hits_bought_today %] today).
[% IF hits_paidfor && user.uid == user_edit.uid %]
	Thank you for supporting [% constants.sitename %]! We appreciate your
	contribution very much.
[% END %]

<p>(We use Greenwich Mean Time to decide where "today" begins and
ends. Your day may vary.)

[% IF can_buy %]

	<form action="[% env.script_name %]">
<fieldset><legend>Buy Subscriptions</legend>
	[% IF user.uid != user_edit.uid %]
	<input type="hidden" name="uid" value="[% user_edit.uid %]">
	[% END %]

[% END %]

[% IF user.is_admin %]

	<p>Want to buy
	[% IF user.uid != user_edit.uid %]"[% user_edit.nickname | strip_literal %]"[% END %]
	some pages? You're an admin, so take as many as you want:
	<input type="text" name="buymore" value="0" size="6">

[% END %]

[% IF can_buy %]

	<p>We give you some control over deciding where to suppress ads.
	New subscribers default to suppressing ads everywhere except on
	comments pages. For accounting purposes, we'd appreciate if you
	had at least one type of ad being suppressed.

	<p><table border=0 cellspacing=1 width="100%">
	<tr><th>&nbsp;&nbsp;Ads&nbsp;&nbsp;</th>
	<th>&nbsp;&nbsp;No&nbsp;Ads&nbsp;&nbsp;</th>
	<th>&nbsp;&nbsp;</th></tr>

	[% FOREACH page = pages %]

	<tr>
	<td valign="top" align="center"><input type="radio"
		name="buypage_[% page.pagename %]"
		value="0"[% IF !page.isbought; constants.markup_checked_attribute; END %]></td>
	<td valign="top" align="center"><input type="radio"
		name="buypage_[% page.pagename %]"
		value="1"[% IF  page.isbought; constants.markup_checked_attribute; END %]></td>
	<td valign="top" align="left">&nbsp;[% page.descr %]</td>
	</tr>

	[% END %]

	<tr><td>&nbsp;</td><td colspan="2" valign="top" align="left"
	>&nbsp;Set "No Ads" anywhere, and you'll get ads disabled for
	free on other pages too.
	(<a href="[% gSkin.rootdir %]/faq/subscriptions.shtml#ss1400">More
	info</a>.)</td></tr>

	</table>

[% END %]

[% IF can_buy %]

	<p>Optionally, if you want to make sure you don't use up
	your subscription too quickly, you may set a limit of the
	maximum number of ads you will suppress per day. Beyond
	this daily limit, pages will not count against your
	subscription (and ads will begin to appear again). Enter
	the value here, or 0 to disable the limit, or blank to
	use the default value
	[% IF constants.subscribe_hits_btmd %]
	of [% constants.subscribe_hits_btmd %][% ELSE %]
	(default is no limit)[% END %]:&nbsp;<INPUT
	type="TEXT" name="hbtm"
	value="[% hits_bought_today_max %]"
	size="6">
	[% IF constants.subscribe_hits_btmd && constants.subscribe_hits_btmd > 2 %]
	<br>Note that setting this value between 1 and
	[% constants.subscribe_hits_btmd - 1 %]
	will disable some
	<a href="[% gSkin.rootdir %]/faq/subscriptions.shtml#ss1600">plums</a>.
	[% END %]

[% END %]

[% IF can_buy %]

	<p><input type="submit" name="op" value="save">
</fieldset>
	</form>

[% END %]
[% IF user.is_admin %]
	<form method="post" action="[% gSkin.rootdir %]/subscribe.pl">
<fieldset>
	<legend>Grant Subscriptions</legend>
	<p>You're an admin so feel free to grant free pages to deserving users.<br>
	Number of pages:<input type="text" name="pages" value="0" size="6">
	User UID:<input type="text" name="uid" value="" size="8">
	<input type="submit" name="op" value="grant">
</fieldset>
	</form>

[% END %]


<p>If you have any questions or concerns about billing, ad&nbsp;display,
or other subscription-related issues, please contact
<a href="mailto:[% constants.subscribe_email %]">[% constants.subscribe_email %]</a>.
If your question is about your daily headlines email, you can edit that at
<a href="[% gSkin.rootdir %]/my/messages">[% gSkin.absolutedir %]/my/messages</a>.
For a list of subscriber-only benefits, see
<a href="[% gSkin.rootdir %]/faq/subscriptions.shtml#ss1600">the FAQ</a>.
</div>
__seclev__
10000
__version__
$Id$
