#!/usr/bin/python
from utils import *
from konst import *
from prefs import *
from cookie import *
import string, sys

if not os.environ.has_key('HTTP_COOKIE'):
    Redirect(kLoginPage)

sys.stderr = sys.stdout

username=GetCookie('user')
if not username:
    Redirect(kLoginPage)

print """Content-Type: text/html\n\n<HTML><HEAD><TITLE>Prefs for status
reports</TITLE>
<STYLE TYPE="text/css">
    .hi { display:inline; background-color: yellow; }
</STYLE>
</HEAD>"""

PrintFile('header.inc')

p = Prefs('%s%s/.prefs' % (kReportsDir, username))
sd = ['', '', '', '', '', '', '']
sd[int(p.submitday)] = 'CHECKED'

sd.append(IfElse(p.autosubmit == '1', 'CHECKED', ''))

print """<TABLE ALIGN=CENTER><TR><TD>
<H3 ALIGN=CENTER>Prefs for Status Reports</H3>

<FORM ACTION="/reports/writeprefs.cgi" METHOD="POST">
<B>Big Day</B> This is the day when you submit your status reports. <BR>
<BLOCKQUOTE>
<TABLE>
<TR><TD VALIGN=TOP>
<INPUT TYPE=RADIO NAME="submitday" VALUE="0" %s> Monday <BR>
<INPUT TYPE=RADIO NAME="submitday" VALUE="1" %s> Tuesday <BR>
</TD><TD VALIGN=TOP>
<INPUT TYPE=RADIO NAME="submitday" VALUE="2" %s> Wednesday <BR>
<INPUT TYPE=RADIO NAME="submitday" VALUE="3" %s> Thursday <BR>
</TD><TD VALIGN=TOP>
<INPUT TYPE=RADIO NAME="submitday" VALUE="4" %s> Friday <BR>
<INPUT TYPE=RADIO NAME="submitday" VALUE="5" %s> Saturday <BR>
</TD><TD VALIGN=TOP>
<INPUT TYPE=RADIO NAME="submitday" VALUE="6" %s> Sunday <BR>
</TD></TR>
<TR><TD COLSPAN=4>
<INPUT TYPE=CHECKBOX NAME="autosubmit" %s> Auto Submit <div class='hi'>COMING SOON!</div> This
will automatically submit whatever status you have entered so far in the
current week. It submits on the day selected above at a minute from midnight. 
</TD>
</TR>
</TABLE>
</BLOCKQUOTE>""" % tuple(sd)

print "Section row size-- <INPUT TYPE=TEXT NAME=rows SIZE=2 VALUE=%s><P>" % p.rows
print """<B>Report sections</B> If your manager requires specific sections for
your status report, add them here. One per line, (format-- file:description)
The 'file' here is the common name by which your manager can check on your
status automatically. 
<BLOCKQUOTE>
<TEXTAREA COLS=40 ROWS=4 NAME="sections">"""

splitchar = ' '
if ',' in p.sectionorder:
    splitchar = ','

for k in string.split(p.sectionorder, splitchar):
    print '%s:%s' % (k, p.sections[k])

bugstat = IfElse(p.bugstat, 'CHECKED', '')
codestat = IfElse(p.codestat, 'CHECKED', '')
revstat = IfElse(p.revstat, 'CHECKED', '')
newstat = IfElse(p.newstat, 'CHECKED', '')

m = IfElse(p.manager, 'CHECKED', '')

print """</TEXTAREA>
</BLOCKQUOTE><P>
<B>Autostats</B> Automatically have some statistics be reported. <div class='hi'>Coming Soon!</div> For now checkout John Keiser's cool queries tool for finding out the work you've done in a given week. It's at <a href=http://www.johnkeiser.com/mozilla/status.html>http://www.johnkeiser.com/mozilla/status.html</a>.
<p> <BLOCKQUOTE>
<INPUT TYPE=CHECKBOX NAME='bugstat' %s><b>Bug statistics</b>. This will
automatically report bugzilla (and bugscape) activities.  Once this is
operational you won't need to list the bugs you fixed in the highlights
section.

<p>
<INPUT TYPE=CHECKBOX NAME='codestat' %s><b>Code statistics</b>. This will
automatically report number of lines of code modified/checked in or removed in
CVS (cvs.mozilla.org) repository in the last week.

<p>
<INPUT TYPE=CHECKBOX NAME='revstat' %s><b>Reviewer statistics</b>. This will
automatically report the number of patches you have reviewed or super-reviewed
in the last week.

<p>
<INPUT TYPE=CHECKBOX NAME='newstat' %s><b>Newsgroup statistics</b>. This will
automatically report number of postings to relevant groups under
netscape.public.mozilla.*

</BLOCKQUOTE><P>

<B>Tracking</B> If you are a manager and would like to track status reports for
your team. 
<BLOCKQUOTE>
<INPUT TYPE=CHECKBOX NAME="manager" %s>Manager<P> """ % (bugstat, codestat, revstat, newstat, m)

print """<B>Team Title</B> :
<INPUT TYPE=TEXT NAME="title" SIZE=40 VALUE="%s"><BR>""" % p.title

print """<B>Team</B> One username on a line. Do not include yourself!
<BLOCKQUOTE>
<TEXTAREA COLS=20 ROWS=3 NAME="team">%s
</TEXTAREA>
</BLOCKQUOTE>
</BLOCKQUOTE><P>""" % string.join(p.team, '\n')

print """<B>Change Passwd</B>
<BLOCKQUOTE>
<TABLE CELLSPACING=0 CELLPADDING=0>
<TR><TD>Current Passwd:</TD><TD><INPUT TYPE=PASSWORD SIZE=20
NAME="current"></TD></TR>
<TR><TD>New Passwd:</TD><TD><INPUT TYPE=PASSWORD SIZE=20
NAME="newpasswd"></TD></TR>
</TABLE>
</BLOCKQUOTE>
<CENTER>
<INPUT TYPE=SUBMIT VALUE="Update">
</CENTER>
</FORM>
</TD></TR></TABLE>"""

PrintFile('footer.inc')
