adding 2 fields to letter system :
authortipaul <tipaul>
Tue, 2 Aug 2005 16:15:34 +0000 (16:15 +0000)
committertipaul <tipaul>
Tue, 2 Aug 2005 16:15:34 +0000 (16:15 +0000)
* module (acquisition, catalogue...) : it will be usefull to show the librarian only letters he may be interested by.
* title, that will be used as mail subject.

admin/letter.pl
koha-tmpl/intranet-tmpl/default/en/parameters/letter.tmpl
updater/updatedatabase

index 1f87dc0..7089773 100755 (executable)
@@ -53,7 +53,7 @@ sub StringSearch  {
        $searchstring=~ s/\'/\\\'/g;
        my @data=split(' ',$searchstring);
        my $count=@data;
-       my $sth=$dbh->prepare("Select * from letter where (code like ?) order by code");
+       my $sth=$dbh->prepare("Select * from letter where (code like ?) order by module,code");
        $sth->execute("$data[0]%");
        my @results;
        my $cnt=0;
@@ -113,7 +113,6 @@ if ($op eq 'add_form') {
        push @SQLfieldname, \%line;
        while ((my $field) = $sth2->fetchrow_array) {
                my %line = ('value' => "biblio.".$field, 'text' => "biblio.".$field);
-               warn "$line{value}";
                push @SQLfieldname, \%line;
        }
        my $sth2=$dbh->prepare("SHOW COLUMNS from biblioitems");
@@ -122,7 +121,6 @@ if ($op eq 'add_form') {
        push @SQLfieldname, \%line;
        while ((my $field) = $sth2->fetchrow_array) {
                my %line = ('value' => "biblioitems.".$field, 'text' => "biblioitems.".$field);
-               warn "$line{value}";
                push @SQLfieldname, \%line;
        }
        my %line = ('value' => "", 'text' => '---ITEMS---');
@@ -136,7 +134,6 @@ if ($op eq 'add_form') {
        push @SQLfieldname, \%line;
        while ((my $field) = $sth2->fetchrow_array) {
                my %line = ('value' => "borrowers.".$field, 'text' => "borrowers.".$field);
-               warn "$line{value}";
                push @SQLfieldname, \%line;
        }
        if ($code) {
@@ -145,7 +142,7 @@ if ($op eq 'add_form') {
        } else {
            $template->param(adding => 1);
        }
-       $template->param(name => $letter->{name},
+       $template->param(name => $letter->{name},title => $letter->{title},
                                        content => $letter->{content},
                                        SQLfieldname => \@SQLfieldname,);
                                                                                                        # END $OP eq ADD_FORM
@@ -153,8 +150,8 @@ if ($op eq 'add_form') {
 # called by add_form, used to insert/modify data in DB
 } elsif ($op eq 'add_validate') {
        my $dbh = C4::Context->dbh;
-       my $sth=$dbh->prepare("replace letter (code,name,content) values (?,?,?)");
-       $sth->execute($input->param('code'),$input->param('name'),$input->param('content'));
+       my $sth=$dbh->prepare("replace letter (module,code,name,title,content) values (?,?,?,?,?)");
+       $sth->execute($input->param('module'),$input->param('code'),$input->param('name'),$input->param('title'),$input->param('content'));
        $sth->finish;
         print $input->redirect("letter.pl");
         exit;
@@ -167,6 +164,7 @@ if ($op eq 'add_form') {
        $sth->execute($code);
        my $data=$sth->fetchrow_hashref;
        $sth->finish;
+       $template->param(module => $data->{module});
        $template->param(code => $code);
        $template->param(name => $data->{'name'});
        $template->param(content => $data->{'content'});
@@ -176,8 +174,9 @@ if ($op eq 'add_form') {
 } elsif ($op eq 'delete_confirmed') {
        my $dbh = C4::Context->dbh;
        my $code=uc($input->param('code'));
-       my $sth=$dbh->prepare("delete from letter where code=?");
-       $sth->execute($code);
+       my $module=$input->param('module');
+       my $sth=$dbh->prepare("delete from letter where module=? and code=?");
+       $sth->execute($module,$code);
        $sth->finish;
         print $input->redirect("letter.pl");
         return;
@@ -200,6 +199,7 @@ if ($op eq 'add_form') {
                }
           my %row_data;
           $row_data{toggle} = $toggle;
+          $row_data{module} = $results->[$i]{'module'};
           $row_data{code} = $results->[$i]{'code'};
           $row_data{name} = $results->[$i]{'name'};
           push(@loop_data, \%row_data);
index 6ec13d9..56cb412 100644 (file)
@@ -4,12 +4,13 @@
        <!-- TMPL_IF NAME="else" -->
                <form action="/cgi-bin/koha/admin/letter.pl" method="post">
                <input type="text" name="searchfield" value="">
-               <input type="submit" class="button" value="OK"></form>
+               <input type="submit" class="button" value="Filter"></form>
                <!-- TMPL_IF NAME="search" -->
                <br>You Searched for <b><!-- TMPL_VAR NAME="searchfield" --></b><p><br>
                <!-- /TMPL_IF -->
                <table>
                <tr>
+                       <th>Module</th>
                        <th>Code</th>
                        <th>Name</th>
                        <th>&nbsp;</th>
@@ -17,6 +18,7 @@
                </tr>
                <!-- TMPL_LOOP NAME="letter" -->
                        <tr bgcolor=<!-- TMPL_VAR NAME="toggle" --> >
+                               <td><!-- TMPL_VAR NAME="module" --></td>
                                <td><!-- TMPL_VAR NAME="code" --></td>
                                <td><!-- TMPL_VAR NAME="name" --></td>
                                <td>
@@ -25,7 +27,7 @@
                                        </a>
                                </td>
                                <td>
-                                       <a href="/cgi-bin/koha/admin/letter.pl?op=delete_confirm&amp;code=<!-- TMPL_VAR NAME="code" -->">
+                                       <a href="/cgi-bin/koha/admin/letter.pl?op=delete_confirm&amp;module=<!-- TMPL_VAR name="module"-->&amp;code=<!-- TMPL_VAR NAME="code" -->">
                                                <img src="<!-- TMPL_VAR NAME="interface" -->/<!-- TMPL_VAR NAME="theme" -->/images/edittrash.png" width="32" hspace="0" vspace="0" border="0">
                                        </a>
                                </td>
                <input type="hidden" name="checked" value="0">
                <!-- TMPL_IF NAME="modify" -->
                        <p>
-                               <label class="label100">Code:</label><input type="hidden" name="code" value="<!-- TMPL_VAR NAME="code" -->"><!-- TMPL_VAR NAME="code" -->
+                               <label class="label100">Koha module:</label>
+                               <select name="module">
+                                       <!-- TMPL_IF name="acquisition" -->
+                                               <option value="acquisition" selected>Acquisition</option>
+                                       <!-- TMPL_ELSE -->
+                                               <option value="acquisition">Acquisition</option>
+                                       <!-- /TMPL_IF -->
+                                       <!-- TMPL_IF name="catalogue" -->
+                                               <option value="catalogue" selected>Catalogue</option>
+                                       <!-- TMPL_ELSE -->
+                                               <option value="catalogue">Catalogue</option>
+                                       <!-- /TMPL_IF -->
+                                       <!-- TMPL_IF name="circulation" -->
+                                               <option value="circulation" selected>Circulation</option>
+                                       <!-- TMPL_ELSE -->
+                                               <option value="circulation">Circulation</option>
+                                       <!-- /TMPL_IF -->
+                                       <!-- TMPL_IF name="members" -->
+                                               <option value="members" selected>Members</option>
+                                       <!-- TMPL_ELSE -->
+                                               <option value="members">Members</option>
+                                       <!-- /TMPL_IF -->
+                                       <!-- TMPL_IF name="authorities" -->
+                                               <option value="authorities" selected>Authorities</option>
+                                       <!-- TMPL_ELSE -->
+                                               <option value="authorities">Authorities</option>
+                                       <!-- /TMPL_IF -->
+                                       <!-- TMPL_IF name="reports" -->
+                                               <option value="reports" selected>Reports</option>
+                                       <!-- TMPL_ELSE -->
+                                               <option value="reports">Reports</option>
+                                       <!-- /TMPL_IF -->
+                                       <!-- TMPL_IF name="parameters" -->
+                                               <option value="parameters" selected>Parameters</option>
+                                       <!-- TMPL_ELSE -->
+                                               <option value="parameters">Parameters</option>
+                                       <!-- /TMPL_IF -->
+                               </select>
                        </p>
                        <p>
-                               <label class="label100">Name:</label><!-- TMPL_VAR NAME="name" -->
+                               <label class="label100">Code:</label><input type="hidden" name="code" value="<!-- TMPL_VAR NAME="code" -->"><!-- TMPL_VAR NAME="code" -->
                        </p>
                <!-- /TMPL_IF -->
                
                <!-- TMPL_IF NAME="adding" -->
+                       <p>
+                               <label class="label100">Koha module:</label>
+                               <select name="module">
+                                               <option value="acquisition">Acquisition</option>
+                                               <option value="catalogue">Catalogue</option>
+                                               <option value="circulation">Circulation</option>
+                                               <option value="members">Members</option>
+                                               <option value="authorities">Authorities</option>
+                                               <option value="reports">Reports</option>
+                                               <option value="parameters">Parameters</option>
+                               </select>
+                       </p>
                        <p>
                                <label class="label100">Code:</label><input type="text" name="code" size="20" maxlength="20">
                        </p>
                        <label class="label100">Name:</label><input type="text" name="name" size="100" value="<!-- TMPL_VAR NAME="name" -->">
                </p>
                <p>
-                       <label class="label100">Content:</label>
+                       <label class="label100">Title (mail subject):</label><input type="text" name="title" size="100" value="<!-- TMPL_VAR NAME="title" -->">
+               </p>
+               <p>
+                       <label class="label100">Content (mail content):</label>
                </p>
                <p><textarea name="content" cols="80" rows="10"><!-- TMPL_VAR NAME="content" --></textarea>
                <input type="button" name="insert" value="&lt;&lt;" onclick="insertValueQuery()" title="Insert" />
        <table border="0" cellspacing="0" cellpadding="5">
                <tr valign="top" bgcolor="#99cc33">
                        <td background="<!-- TMPL_VAR NAME="themelang" -->/images/background-mem.gif">
-                               <b>Code</b>
+                               <b>module / Code</b>
                        </td>
                        <td background="<!-- TMPL_VAR NAME="themelang" -->/images/background-mem.gif">
-                               <b><!-- TMPL_VAR NAME="code" --></b>
+                               <b><!-- TMPL_VAR name="module"--> / <!-- TMPL_VAR NAME="code" --></b>
                        </td>
                </tr>
        
                <form action="<!-- TMPL_VAR NAME="action" -->" method="post"><input type="hidden" name="op" value="delete_confirmed">
                <input type="hidden" name="code" value="<!-- TMPL_VAR NAME="code" -->">
+               <input type="hidden" name="module" value="<!-- TMPL_VAR NAME="module" -->">
                <tr>
                        <td>Name</td>
                        <td><!-- TMPL_VAR NAME="Name" --></td>
                        <td colspan="2" align="center">CONFIRM DELETION</td>
                </tr>
                <tr>
-                       <td><input type="submit" value="YES"></form></td><td><form action="<!-- TMPL_VAR NAME="action" -->" method="post"><input type="submit" value="NO"></form></td>
+                       <td>
+                               <input type="submit" value="YES">
+                               </form>
+                       </td>
+                       <td>
+                               <form action="<!-- TMPL_VAR NAME="action" -->" method="post">
+                                       <input type="submit" value="NO">
+                               </form>
+                       </td>
                </tr>
        </table>
        <!-- /TMPL_IF -->
index 82615f2..38614fb 100755 (executable)
@@ -73,10 +73,12 @@ my %requiretables = (
                                    PRIMARY KEY ( `timestamp` , `user` )
                            )",
        letter          => "(
-                                       code varchar(20) NOT NULL,
-                                       name varchar(100) NOT NULL,
-                                       content TEXT,
-                                       PRIMARY KEY (code)
+                                       module varchar(20) NOT NULL default '',
+                                       code varchar(20) NOT NULL default '',
+                                       name varchar(100) NOT NULL default '',
+                                       title varchar(200) NOT NULL default '',
+                                       content text,
+                                       PRIMARY KEY  (module,code)
                                )",
 );
 
@@ -356,6 +358,11 @@ $sth->finish;
 exit;
 
 # $Log$
+# Revision 1.115  2005/08/02 16:15:34  tipaul
+# adding 2 fields to letter system :
+# * module (acquisition, catalogue...) : it will be usefull to show the librarian only letters he may be interested by.
+# * title, that will be used as mail subject.
+#
 # Revision 1.114  2005/07/28 15:10:13  tipaul
 # Introducing new "Letters" system : Letters will be used everytime you want to sent something to someone (through mail or paper). For example, sending a mail for overdues use letter that you can put as parameters. Sending a mail to a borrower when a suggestion is validated uses a letter too.
 # the letter table contains 3 fields :
@@ -737,6 +744,11 @@ $sth->finish;
 exit;
 
 # $Log$
+# Revision 1.115  2005/08/02 16:15:34  tipaul
+# adding 2 fields to letter system :
+# * module (acquisition, catalogue...) : it will be usefull to show the librarian only letters he may be interested by.
+# * title, that will be used as mail subject.
+#
 # Revision 1.114  2005/07/28 15:10:13  tipaul
 # Introducing new "Letters" system : Letters will be used everytime you want to sent something to someone (through mail or paper). For example, sending a mail for overdues use letter that you can put as parameters. Sending a mail to a borrower when a suggestion is validated uses a letter too.
 # the letter table contains 3 fields :