cust_attachment improvement, RT#4964 and #6225
authormark <mark>
Tue, 17 Nov 2009 00:06:25 +0000 (00:06 +0000)
committermark <mark>
Tue, 17 Nov 2009 00:06:25 +0000 (00:06 +0000)
httemplate/edit/cust_main_attach.cgi
httemplate/edit/process/cust_main_attach.cgi
httemplate/elements/menu.html
httemplate/search/elements/search-html.html
httemplate/view/cust_main.cgi
httemplate/view/cust_main/attachments.html

index 43d2e29..5e9b16c 100755 (executable)
@@ -2,31 +2,39 @@
 
 <% include('/elements/error.html') %>
 
-<FORM ACTION="<% popurl(1) %>process/cust_main_attach.cgi" METHOD=POST ENCTYPE="multipart/form-data">
+<FORM NAME="attach_edit" ACTION="<% popurl(1) %>process/cust_main_attach.cgi" METHOD=POST ENCTYPE="multipart/form-data">
 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
 <INPUT TYPE="hidden" NAME="attachnum" VALUE="<% $attachnum %>">
 
 <BR><BR>
 
+<% include('/elements/table.html') %>
 % if(defined $attach) {
-Filename <INPUT TYPE="text" NAME="filename" VALUE="<% $attach->filename %>"><BR>
-MIME type <INPUT TYPE="text" NAME="mime_type" VALUE="<% $attach->mime_type %>"<BR>
-Size: <% $attach->size %><BR>
-
+%   if($curuser->access_right("Download attachment")) {
+<A HREF="<% $p.'view/attachment.html?'.$attachnum %>">Download this file</A><BR>
+%   }
+<TR><TD> Filename </TD>
+<TD><INPUT TYPE="text" NAME="filename" SIZE=32 MAXLENGTH=32 VALUE="<% $attach->filename %>"<% $disabled %>></TD></TR>
+<TR><TD> Description </TD>
+<TD><INPUT TYPE="text" NAME="title" SIZE=32 MAXLENGTH=32 VALUE="<% $attach->title %>"<% $disabled %></TD></TR>
+<TR><TD> MIME type </TD>
+<TD><INPUT TYPE="text" NAME="mime_type" VALUE="<% $attach->mime_type %>"<% $disabled %></TD></TR>
+<TR><TD> Size </TD><TD><% $attach->size %></TD></TR>
 % }
 % else { # !defined $attach
-
-Filename <INPUT TYPE="file" NAME="file"><BR>
-
+<TR><TD> Filename </TD><TD><INPUT TYPE="file" SIZE=32 NAME="file"></TD></TR>
+<TR><TD> Description </TD><TD><INPUT TYPE="text" NAME="title" SIZE=32 MAXLENGTH=32></TD></TR>
 % }
-
+</TABLE>
 <BR>
+% if(! $disabled) {
 <INPUT TYPE="submit" NAME="submit" 
     VALUE="<% $attachnum ? "Apply Changes" : "Upload File" %>">
-
+% }
 % if(defined $attach and $curuser->access_right('Delete attachment')) {
 <BR>
-<INPUT TYPE="submit" NAME="delete" value="Delete File">
+<INPUT TYPE="submit" NAME="delete" value="Delete File" 
+onclick="return(confirm('Delete this file?'));">
 % }
 
 </FORM>
@@ -47,13 +55,15 @@ if ( $cgi->param('error') ) {
   die "no such attachment: ". $attachnum unless $attach;
 }
 
-$cgi->param('custnum') =~ /^(\d+)$/ or die "illegal custnum";
-my $custnum = $1;
-
 my $action = $attachnum ? 'Edit' : 'Add';
 
-die "access denied"
-  unless $curuser->access_right("$action attachment");
+my $disabled='';
+if(! $curuser->access_right("$action attachment")) {
+  $disabled = ' disabled="disabled"';
+}
+
+$cgi->param('custnum') =~ /^(\d+)$/ or die "illegal custnum";
+my $custnum = $1;
 
 </%init>
 
index 98f4d09..0927141 100644 (file)
@@ -53,6 +53,7 @@ if($attachnum) {
       ('_date', 'otaker', 'body', 'disabled');
     $new->filename($cgi->param('filename') || $old->filename);
     $new->mime_type($cgi->param('mime_type') || $old->mime_type);
+    $new->title($cgi->param('title'));
     if($delete and not $old->disabled) {
       $new->disabled(time);
     }
@@ -67,6 +68,7 @@ else { # This is a new attachment, so require a file.
   if($filename) {
     $new->filename($filename);
     $new->mime_type($cgi->uploadInfo($filename)->{'Content-Type'});
+    $new->title($cgi->param('title'));
     
     local $/;
     my $fh = $cgi->upload('file');
index cd54661..5329350 100644 (file)
@@ -321,6 +321,8 @@ $tools_menu{'Ticketing'} = [ \%tools_ticketing, 'Ticketing tools' ]
   if $conf->config('ticket_system');
 $tools_menu{'Time Queue'} =  [ $fsurl.'search/timeworked.html', 'View pending support time' ]
   if $curuser->access_right('Time queue');
+$tools_menu{'Attachments'} = [ $fsurl.'browse/cust_attachment.html', 'View customer attachments' ]
+  if !$conf->config('disable_cust_attachment');
 $tools_menu{'Importing'} =  [ \%tools_importing, 'Import tools' ]
   if $curuser->access_right('Import');
 $tools_menu{'Exporting'} =  [ \%tools_exporting, 'Export tools' ]
index 297774d..c0bb721 100644 (file)
 %                             }
 %                             $a = qq(<A HREF="$a"$onclick>);
 %                           }
-%
+%                           elsif ( $onclick ) {
+%                             $a = qq(<A HREF="javascript:void(0);"$onclick>);
+%                           }
 %                         }
 %
 %                       }
index 314207b..08d99d8 100755 (executable)
@@ -148,8 +148,8 @@ Comments
               'action'      => $p.'edit/cust_main_attach.cgi',
               'actionlabel' => 'Upload file',
               'cust_main'   => $cust_main,
-              'width'       => 616,
-              'height'      => 408,
+              'width'       => 480,
+              'height'      => 296,
           )
 %>
 % }
index 53635fd..dbb29a7 100755 (executable)
@@ -11,6 +11,7 @@
 %   }
     <TH CLASS="grid" BGCOLOR="#cccccc">Person</TH>
     <TH CLASS="grid" BGCOLOR="#cccccc">Filename</TH>
+    <TH CLASS="grid" BGCOLOR="#cccccc">Description</TH>
     <TH CLASS="grid" BGCOLOR="#cccccc">Type</TH>
     <TH CLASS="grid" BGCOLOR="#cccccc">Size</TH>
     <TH CLASS="grid" BGCOLOR="#cccccc"></TH>
@@ -54,7 +55,8 @@
 %       my $clickjs = popup('edit/process/cust_main_attach.cgi?'.
 %                           "custnum=$custnum;attachnum=$attachnum;".
 %                           "purge=1",
-%                           'Purge attachment');
+%                           'Purge attachment',
+%                           'Permanently remove this file?');
 %       $edit .= qq!&nbsp; <A HREF="javascript:void(0);" $clickjs>(purge)</A>!;
 %     }
 %   }
@@ -67,9 +69,9 @@
 %     }
 %     if($curuser->access_right('Delete attachment') ) {
 %       my $clickjs = popup('edit/process/cust_main_attach.cgi?'.
-%                           "custnum=$custnum;attachnum=$attachnum;".
-%                           "delete=1",
-%                           'Delete attachment');
+%                           "custnum=$custnum;attachnum=$attachnum;delete=1",
+%                           'Delete attachment',
+%                           'Delete this file?');
 %       $edit .= qq!&nbsp; <A HREF="javascript:void(0);" $clickjs>(delete)</A>!;
 %     }
 %     if ($curuser->access_right('Download attachment') ) {
@@ -86,6 +88,8 @@
        &nbsp;<% $attach->filename %>
       </TD>
       <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+       &nbsp;<% $attach->title %>
+      <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
        &nbsp;<% $attach->mime_type %>
       </TD>
       <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
@@ -135,15 +139,16 @@ sub size_units {
 }
 
 sub popup {
-  my ($url, $label) = @_;
+  my ($url, $label, $confirm) = @_;
   my $onclick = 
     include('/elements/popup_link_onclick.html',
       'action'     => popurl(2).$url,
       'actionlabel' => $label,
-      'width'       => 616,
-      'height'      => 408,
+      'width'       => 510,
+      'height'      => 315,
       'frame'       => 'top',
     );
+  $onclick = qq!if(confirm('$confirm')) { $onclick }! if $confirm;
   return qq!onclick="$onclick"!;
 }