summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorjeff <jeff>2006-10-03 22:44:28 +0000
committerjeff <jeff>2006-10-03 22:44:28 +0000
commit30c3ff2acf90e1386fae00759078899c859faf36 (patch)
tree75fd2a828c64a2b7bd2d2f4c650d058af726e241 /httemplate
parent40f370f0fbc6dedee27b8666f7d00e3888a1533b (diff)
Enhanced customer notes
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/edit/cust_main.cgi7
-rwxr-xr-xhttemplate/edit/cust_main_note.cgi37
-rwxr-xr-xhttemplate/edit/process/cust_main_note.cgi34
-rwxr-xr-xhttemplate/view/cust_main.cgi28
-rwxr-xr-xhttemplate/view/cust_main/notes.html74
5 files changed, 178 insertions, 2 deletions
diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi
index dfcd0401f..99f849fc8 100755
--- a/httemplate/edit/cust_main.cgi
+++ b/httemplate/edit/cust_main.cgi
@@ -359,17 +359,20 @@ function copyelement(from, to) {
<INPUT TYPE="hidden" NAME="<% $hidden %>" VALUE="">
% }
-
+%
+% my $ro_comments = $conf->exists('cust_main-use_comments')?'':'readonly';
+% if (!$ro_comments || $cust_main->comments) {
<BR>Comments
<% &ntable("#cccccc") %>
<TR>
<TD>
- <TEXTAREA COLS=80 ROWS=5 WRAP="HARD" NAME="comments"><% $cust_main->comments %></TEXTAREA>
+ <TEXTAREA COLS=80 ROWS=5 WRAP="HARD" NAME="comments" <%$ro_comments%>><% $cust_main->comments %></TEXTAREA>
</TD>
</TR>
</TABLE>
%
+% }
%
%unless ( $custnum ) {
% # pry the wrong place for this logic. also pretty expensive
diff --git a/httemplate/edit/cust_main_note.cgi b/httemplate/edit/cust_main_note.cgi
new file mode 100755
index 000000000..468ef0051
--- /dev/null
+++ b/httemplate/edit/cust_main_note.cgi
@@ -0,0 +1,37 @@
+<% include('/elements/header-popup.html', 'Add Customer Note') %>
+
+% if ( $cgi->param('error') ) {
+ <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT>
+ <BR><BR>
+% }
+
+<FORM ACTION="<% popurl(1) %>process/cust_main_note.cgi" METHOD=POST>
+<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
+
+
+<BR><BR>
+<TEXTAREA NAME="comment" ROWS="12" COLS="60">
+<% $comment %>
+</TEXTAREA>
+
+<BR><BR>
+<INPUT TYPE="submit" VALUE="Add note">
+
+</FORM>
+</BODY>
+</HTML>
+
+<%init>
+my($custnum, $comment);
+$comment = '';
+
+if ( $cgi->param('error') ) {
+ $comment = $cgi->param('comment');
+}
+$cgi->param('custnum') =~ /^(\d+)$/;
+$custnum = $1;
+
+die "illegal query ". $cgi->keywords unless $custnum;
+
+</%init>
+
diff --git a/httemplate/edit/process/cust_main_note.cgi b/httemplate/edit/process/cust_main_note.cgi
new file mode 100755
index 000000000..d9251f042
--- /dev/null
+++ b/httemplate/edit/process/cust_main_note.cgi
@@ -0,0 +1,34 @@
+%
+%
+%$cgi->param('custnum') =~ /^(\d+)$/
+% or die "Illegal custnum: ". $cgi->param('custnum');
+%my $custnum = $1;
+%
+%my $otaker = $FS::CurrentUser::CurrentUser->name;
+%$otaker = $FS::CurrentUser::CurrentUser->username
+% if ($otaker eq "User, Legacy");
+%
+%my $new = new FS::cust_main_note ( {
+% custnum => $custnum,
+% _date => time,
+% otaker => $otaker,
+% comments => $cgi->param('comment'),
+%} );
+%
+%my $error = $new->insert;
+%
+%if ($error) {
+% $cgi->param('error', $error);
+% print $cgi->redirect(popurl(2). 'cust_main_note.cgi?'. $cgi->query_string );
+%}
+%
+%
+<% header('Note added') %>
+ <SCRIPT TYPE="text/javascript">
+ window.top.location.reload();
+ </SCRIPT>
+
+ </BODY></HTML>
+%
+%
+
diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi
index e82a5196c..6b2277756 100755
--- a/httemplate/view/cust_main.cgi
+++ b/httemplate/view/cust_main.cgi
@@ -116,6 +116,34 @@ Comments
</TR>
</TABLE></TABLE>
% }
+<BR><BR>
+% my $notecount = scalar($cust_main->notes());
+% if ($conf->exists('cust_main-use_notes') || $notecount) {
+
+<A NAME="cust_main_note"><FONT SIZE="+2">Notes</FONT></A><BR>
+% if ( $curuser->access_right('Add customer note') &&
+% $conf->exists('cust_main-use_notes')
+% ) {
+
+ <A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('<% $p %>edit/cust_main_note.cgi?custnum=<% $cust_main->custnum %>', 616, 386, 'cust_main_note_popup' ), CAPTION, 'Enter customer note', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK); return false;">Add customer note</A>
+
+% }
+
+<BR>
+
+% if ($notecount) {
+
+<iframe src="<% $p %>view/cust_main/notes.html?custnum=<% $cust_main->custnum %>" height="186" width="616" name="cust_main_notes" frameborder="0" marginborder="0" marginheight="0" scrolling="auto">
+ <div><br>[iframe not supported]<br><br></div>
+</iframe>
+
+% } else {
+
+<BR>
+% }
+% }
+
+
% if ( $conf->config('ticket_system') ) {
<BR>
diff --git a/httemplate/view/cust_main/notes.html b/httemplate/view/cust_main/notes.html
new file mode 100755
index 000000000..c1a33b020
--- /dev/null
+++ b/httemplate/view/cust_main/notes.html
@@ -0,0 +1,74 @@
+%
+% my $conf = new FS::Conf;
+%
+% $cgi->param('custnum') =~ /^(\d+)$/
+% or die "No customer specified (bad URL)!";
+% my $custnum = $1;
+%
+% my $cust_main = qsearchs('cust_main', {'custnum' => $custnum} );
+% die "Custimer not found!" unless $cust_main;
+%
+% my (@notes) = $cust_main->notes();
+% if ( scalar(@notes) ) {
+
+<STYLE TYPE="text/css">
+
+body { background: #e8e8e8 }
+.inv table { border: none }
+.inv TH { border: none }
+.inv TD { border: none }
+
+</STYLE>
+
+<TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0 BORDER=0 >
+
+%#<% include('/elements/table-grid.html') %>
+% my $bgcolor1 = '#eeeeee';
+% my $bgcolor2 = '#ffffff';
+% my $bgcolor = '';
+%
+% foreach my $note (@notes) {
+%
+% if ( $bgcolor eq $bgcolor1 ) {
+% $bgcolor = $bgcolor2;
+% } else {
+% $bgcolor = $bgcolor1;
+% }
+%
+%
+
+<TR>
+ <% note_datestr($note,$conf,$bgcolor) %>
+ <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
+ &nbsp;<%$note->otaker%>&nbsp;
+ </TD>
+ <TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
+ &nbsp;<%$note->comments%>
+ </TD>
+</TR>
+
+% } #end display notes
+
+</TABLE>
+% } else {
+
+<BR>
+% }
+%
+%#subroutines
+%
+%sub note_datestr {
+% my($note, $conf, $bgcolor) = @_ or return '';
+% my $format=qq{<TD class="inv" bgcolor="$bgcolor" align="left"><B>%b</B></TD>}.
+% qq{<TD class="inv" bgcolor="$bgcolor" align="right"><B>&nbsp;%o,</B></TD>}.
+% qq{<TD class="inv" bgcolor="$bgcolor" align="right"><B>&nbsp;%Y&nbsp;</B></TD>};
+% $format .= qq{<TD class="inv" bgcolor="$bgcolor" ALIGN="right"><B>&nbsp;%l</TD>}.
+% qq{<TD class="inv" bgcolor="$bgcolor" ALIGN="center"><B>:</B></TD>}.
+% qq{<TD class="inv" bgcolor="$bgcolor" ALIGN="left"><B>%M</B></TD>}.
+% qq{<TD class="inv" bgcolor="$bgcolor" ALIGN="left"><B>&nbsp;%P&nbsp;</B></TD>}
+% if $conf->exists('cust_main_note-display_times');
+% ( my $strip = time2str($format, $note->_date) ) =~ s/ (\d)/$1/g;
+% $strip;
+% }
+%
+