[Patches] [PATCH] Bug 5347: Adds columns claims_count and claimed_date in

koha-patchbot at kohaaloha.com koha-patchbot at kohaaloha.com
Sat Dec 3 14:16:23 NZDT 2011


From: Jonathan Druart <jonathan.druart at biblibre.com>
Date: Fri, 2 Dec 2011 14:03:50 +0100
Subject: [PATCH] Bug 5347: Adds columns claims_count and claimed_date in
 aqorders

This patch adds 2 columns in the aqorders table :
- claims_count : number of claims for an orders
- claimed_date : date of the lastest claim

In the lateorders.pl table, you can not select orders from different
supplier because there is just one letter sent after clicking the "Claim
order" button. So, it's logic that you want to select only orders from
this supplier.

Modification in C4/Letters.pm:
refactoring code for claimacquisition and claimissues letter type.
Now, fields for theses letters check the table name. It's not possible
to chooce aqorders.title, this field doesn't exist !
Furthermore, you can add a <item> tag around your item fields, like
this :

-- Begin example
<<LibrarianFirstname>>
<<LibrarianSurname>>

<<aqbooksellers.contact>>
<<aqbooksellers.address1>>
<<aqbooksellers.phone>>
<<aqbasket.basketno>>
<<aqbooksellers.phone>>
<item>Library : <<items.homebranch>>
In your possesssion : <<biblio.author>>. <<biblio.title>>.
<<biblioitems.publishercode>>, <<biblioitems.publicationyear>>.
Callnumber : <<items.itemcallnumber>>. doc type : <<items.itype>>
Barcode : <<items.barcode>>
Date for the return : <<items.onloan>>.</item>

<<LibrarianSurname>>
-- End example
---
 C4/Acquisition.pm                                  |   30 +++
 C4/Letters.pm                                      |  198 ++++++++------------
 acqui/lateorders.pl                                |   18 ++-
 .../data/mysql/en/mandatory/sample_notices.sql     |    2 +-
 .../mysql/fr-FR/1-Obligatoire/sample_notices.sql   |    2 +-
 installer/data/mysql/kohastructure.sql             |    2 +
 .../data/mysql/pl-PL/mandatory/sample_notices.sql  |    2 +-
 .../data/mysql/ru-RU/mandatory/sample_notices.sql  |    2 +-
 .../data/mysql/ru-RU/optional/sample_notices.sql   |    2 +-
 .../data/mysql/uk-UA/mandatory/sample_notices.sql  |    2 +-
 .../data/mysql/uk-UA/optional/sample_notices.sql   |    2 +-
 installer/data/mysql/updatedatabase.pl             |    6 +
 .../intranet-tmpl/prog/en/css/staff-global.css     |   10 +-
 .../prog/en/modules/acqui/lateorders.tt            |   39 ++++-
 14 files changed, 185 insertions(+), 132 deletions(-)

diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm
index 7127f24..e1d18f5 100644
--- a/C4/Acquisition.pm
+++ b/C4/Acquisition.pm
@@ -61,6 +61,8 @@ BEGIN {
         &GetContracts &GetContract
 
         &GetItemnumbersFromOrder
+
+        &AddClaim
     );
 }
 
@@ -1416,9 +1418,12 @@ sub GetLateOrders {
         DATE(aqbasket.closedate)  AS orderdate,
         aqorders.rrp              AS unitpricesupplier,
         aqorders.ecost            AS unitpricelib,
+        aqorders.claims_count     AS claims_count,
+        aqorders.claimed_date     AS claimed_date,
         aqbudgets.budget_name     AS budget,
         borrowers.branchcode      AS branch,
         aqbooksellers.name        AS supplier,
+        aqbooksellers.id          AS supplierid,
         biblio.author, biblio.title,
         biblioitems.publishercode AS publisher,
         biblioitems.publicationyear,
@@ -1742,6 +1747,31 @@ sub GetContract {
     return $result;
 }
 
+=head3 AddClaim
+
+=over 4
+
+&AddClaim($ordernumber);
+
+Add a claim for an order
+
+=back
+
+=cut
+sub AddClaim {
+    my ($ordernumber) = @_;
+    my $dbh          = C4::Context->dbh;
+    my $query        = "
+        UPDATE aqorders SET
+            claims_count = claims_count + 1,
+            claimed_date = CURDATE()
+        WHERE ordernumber = ?
+        ";
+    my $sth = $dbh->prepare($query);
+    $sth->execute($ordernumber);
+
+}
+
 1;
 __END__
 
diff --git a/C4/Letters.pm b/C4/Letters.pm
index 6846a00..edd93a1 100644
--- a/C4/Letters.pm
+++ b/C4/Letters.pm
@@ -243,6 +243,7 @@ sub findrelatedto ($$) {
 sub SendAlerts {
     my ( $type, $externalid, $letter ) = @_;
     my $dbh = C4::Context->dbh;
+    my $strsth;
     if ( $type eq 'issue' ) {
 
         # 		warn "sending issues...";
@@ -290,99 +291,56 @@ sub SendAlerts {
                     );
                 sendmail(%mail) or carp $Mail::Sendmail::error;
 
-# warn "sending to $mail{To} From $mail{From} subj $mail{Subject} Mess $mail{Message}";
             }
         }
     }
     elsif ( $type eq 'claimacquisition' ) {
 
-        # 		warn "sending issues...";
-        my $letter = getletter( 'claimacquisition', $letter );
+        $letter = getletter( 'claimacquisition', $letter );
 
         # prepare the letter...
         # search the biblionumber
-        my $strsth =
-"select aqorders.*,aqbasket.*,biblio.*,biblioitems.* from aqorders LEFT JOIN aqbasket on aqbasket.basketno=aqorders.basketno LEFT JOIN biblio on aqorders.biblionumber=biblio.biblionumber LEFT JOIN biblioitems on aqorders.biblioitemnumber=biblioitems.biblioitemnumber where aqorders.ordernumber IN ("
-          . join( ",", @$externalid ) . ")";
-        my $sthorders = $dbh->prepare($strsth);
-        $sthorders->execute;
-        my $dataorders = $sthorders->fetchall_arrayref( {} );
-        parseletter( $letter, 'aqbooksellers',
-            $dataorders->[0]->{booksellerid} );
-        my $sthbookseller =
-          $dbh->prepare("select * from aqbooksellers where id=?");
-        $sthbookseller->execute( $dataorders->[0]->{booksellerid} );
-        my $databookseller = $sthbookseller->fetchrow_hashref;
-
-        # parsing branch info
-        my $userenv = C4::Context->userenv;
-        parseletter( $letter, 'branches', $userenv->{branch} );
-
-        # parsing librarian name
-        $letter->{content} =~ s/<<LibrarianFirstname>>/$userenv->{firstname}/g;
-        $letter->{content} =~ s/<<LibrarianSurname>>/$userenv->{surname}/g;
-        $letter->{content} =~
-          s/<<LibrarianEmailaddress>>/$userenv->{emailaddress}/g;
-        foreach my $data ( @{$dataorders} ) {
-            if ( $letter->{content} =~ m/(<<.*>>)/ ) {
-                my $line = $1;
-                foreach my $field ( keys %{$data} ) {
-                    $line =~ s/(<<[^\.]+.$field>>)/$data->{$field}/;
-                }
-                $letter->{content} =~ s/(<<.*>>)/$line\n$1/;
-            }
-        }
-        $letter->{content} =~ s/<<[^>]*>>//g;
-        my $innerletter = $letter;
-
-        # ... then send mail
-        if (   $databookseller->{bookselleremail}
-            || $databookseller->{contemail} )
-        {
-            my %mail = (
-                To => $databookseller->{bookselleremail}
-                  . (
-                    $databookseller->{contemail}
-                    ? "," . $databookseller->{contemail}
-                    : ""
-                  ),
-                From           => $userenv->{emailaddress},
-                Subject        => "" . $innerletter->{title},
-                Message        => "" . $innerletter->{content},
-                'Content-Type' => 'text/plain; charset="utf8"',
-            );
-            sendmail(%mail) or carp $Mail::Sendmail::error;
-        }
-        if ( C4::Context->preference("LetterLog") ) {
-            logaction(
-                "ACQUISITION",
-                "Send Acquisition claim letter",
-                "",
-                "order list : "
-                  . join( ",", @$externalid )
-                  . "\n$innerletter->{title}\n$innerletter->{content}"
-            );
+        $strsth = qq{
+            SELECT aqorders.*,aqbasket.*,biblio.*,biblioitems.*,aqbooksellers.*
+            FROM aqorders
+            LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
+            LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber
+            LEFT JOIN biblioitems ON aqorders.biblioitemnumber=biblioitems.biblioitemnumber
+            LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
+            WHERE aqorders.ordernumber IN (
         }
+          . join( ",", @$externalid ) . ")";
     }
     elsif ( $type eq 'claimissues' ) {
 
-        # 		warn "sending issues...";
-        my $letter = getletter( 'claimissues', $letter );
+        $letter = getletter( 'claimissues', $letter );
 
         # prepare the letter...
         # search the biblionumber
-        my $strsth =
-"select serial.*,subscription.*, biblio.* from serial LEFT JOIN subscription on serial.subscriptionid=subscription.subscriptionid LEFT JOIN biblio on serial.biblionumber=biblio.biblionumber where serial.serialid IN ("
+        $strsth = qq{
+            SELECT serial.*,subscription.*, biblio.*, aqbooksellers.*
+            FROM serial
+            LEFT JOIN subscription ON serial.subscriptionid=subscription.subscriptionid
+            LEFT JOIN biblio ON serial.biblionumber=biblio.biblionumber
+            LEFT JOIN aqbooksellers ON subscription.aqbooksellerid=aqbooksellers.id
+            WHERE serial.serialid IN (
+        }
           . join( ",", @$externalid ) . ")";
+    }
+
+    if ( $type eq 'claimacquisition' or $type eq 'claimissues' ) {
         my $sthorders = $dbh->prepare($strsth);
         $sthorders->execute;
-        my $dataorders = $sthorders->fetchall_arrayref( {} );
-        parseletter( $letter, 'aqbooksellers',
-            $dataorders->[0]->{aqbooksellerid} );
-        my $sthbookseller =
-          $dbh->prepare("select * from aqbooksellers where id=?");
-        $sthbookseller->execute( $dataorders->[0]->{aqbooksellerid} );
-        my $databookseller = $sthbookseller->fetchrow_hashref;
+        my @fields = map {
+            $sthorders->{mysql_table}[$_] . "." . $sthorders->{NAME}[$_] }
+            (0 .. $#{$sthorders->{NAME}} ) ;
+
+        my @orders_infos;
+        while ( my $row = $sthorders->fetchrow_arrayref() ) {
+            my %rec = ();
+            @rec{@fields} = @$row;
+            push @orders_infos, \%rec;
+        }
 
         # parsing branch info
         my $userenv = C4::Context->userenv;
@@ -391,59 +349,65 @@ sub SendAlerts {
         # parsing librarian name
         $letter->{content} =~ s/<<LibrarianFirstname>>/$userenv->{firstname}/g;
         $letter->{content} =~ s/<<LibrarianSurname>>/$userenv->{surname}/g;
-        $letter->{content} =~
-          s/<<LibrarianEmailaddress>>/$userenv->{emailaddress}/g;
-        foreach my $data ( @{$dataorders} ) {
-            if ( $letter->{content} =~ m/(<<.*>>)/ ) {
-                my $line = $1;
-                foreach my $field ( keys %{$data} ) {
-                    $line =~ s/(<<[^\.]+.$field>>)/$data->{$field}/;
+        $letter->{content} =~ s/<<LibrarianEmailaddress>>/$userenv->{emailaddress}/g;
+
+        # Get Fields remplacement
+        my $item_format = $1 if ( $letter->{content} =~ m/(<item>.*<\/item>)/xms );
+
+        # Foreach field to remplace
+        while ( $letter->{content} =~ m/<<([^>]*)>>/g ) {
+            my $field = $1;
+            my $value = $orders_infos[0]->{$field} || "";
+            $value = sprintf("%.2f", $value) if $field =~ /price/;
+            $letter->{content} =~ s/<<$field>>/$value/g;
+        }
+
+        if ( $item_format ) {
+            # For each order
+            foreach my $infos ( @orders_infos ) {
+                my $order_content = $item_format;
+                # We replace by value
+                while ( $order_content =~ m/<<([^>]*)>>/g ) {
+                    my $field = $1;
+                    my $value = $infos->{$field} || "";
+                    $value = sprintf("%.2f", $value) if $field =~ /price/;
+                    $order_content =~ s/(<<$field>>)/$value/g;
                 }
-                $letter->{content} =~ s/(<<.*>>)/$line\n$1/;
+                $order_content =~ s/<\/{0,1}?item>//g;
+                $letter->{content} =~ s/<item>.*<\/item>/$order_content\n$item_format/xms;
             }
+            $letter->{content} =~ s/<item>.*<\/item>//xms;
         }
-        $letter->{content} =~ s/<<[^>]*>>//g;
+
         my $innerletter = $letter;
 
         # ... then send mail
-        if (   $databookseller->{bookselleremail}
-            || $databookseller->{contemail} ) {
-            my $mail_to = $databookseller->{bookselleremail};
-            if ($databookseller->{contemail}) {
-                if (!$mail_to) {
-                    $mail_to = $databookseller->{contemail};
-                } else {
-                    $mail_to .= q|,|;
-                    $mail_to .= $databookseller->{contemail};
-                }
-            }
-            my $mail_subj = $innerletter->{title};
-            my $mail_msg  = $innerletter->{content};
-            $mail_msg  ||= q{};
-            $mail_subj ||= q{};
-
+        if (   $orders_infos[0]->{'aqbooksellers.bookselleremail'}
+            || $orders_infos[0]->{'aqbooksellers.contemail'} ) {
+            my $to = $orders_infos[0]->{'aqbooksellers.bookselleremail'};
+            $to .= ", " if $to;
+            $to .= $orders_infos[0]->{'aqbooksellers.contemail'} || "";
             my %mail = (
-                To => $mail_to,
-                From    => $userenv->{emailaddress},
-                Subject => $mail_subj,
-                Message => $mail_msg,
+                To             => $to,
+                From           => $userenv->{emailaddress},
+                Subject        => "" . $innerletter->{title},
+                Message        => "" . $innerletter->{content},
                 'Content-Type' => 'text/plain; charset="utf8"',
             );
             sendmail(%mail) or carp $Mail::Sendmail::error;
-            logaction(
-                "ACQUISITION",
-                "CLAIM ISSUE",
-                undef,
-                "To="
-                  . $databookseller->{contemail}
-                  . " Title="
-                  . $innerletter->{title}
-                  . " Content="
-                  . $innerletter->{content}
-            ) if C4::Context->preference("LetterLog");
+            warn "sending to $mail{To} From $mail{From} subj $mail{Subject} Mess $mail{Message}";
+            if ( C4::Context->preference("LetterLog") ) {
+                logaction( "ACQUISITION", "Send Acquisition claim letter", "", "order list : " . join( ",", @$externalid ) . "\n$innerletter->{title}\n$innerletter->{content}" ) if $type eq 'claimacquisition';
+                logaction( "ACQUISITION", "CLAIM ISSUE", undef, "To=" . $mail{To} . " Title=" . $innerletter->{title} . " Content=" . $innerletter->{content} ) if $type eq 'claimissues';
+            }
+        } else {
+            die "This bookseller have no email\n";
         }
-    }    
-   # send an "account details" notice to a newly created user 
+
+        warn "sending to From $userenv->{emailaddress} subj $innerletter->{title} Mess $innerletter->{content}";
+    }
+
+    # send an "account details" notice to a newly created user 
     elsif ( $type eq 'members' ) {
         # must parse the password special, before it's hashed.
         $letter->{content} =~ s/<<borrowers.password>>/$externalid->{'password'}/g;
diff --git a/acqui/lateorders.pl b/acqui/lateorders.pl
index 810f665..fe27de4 100755
--- a/acqui/lateorders.pl
+++ b/acqui/lateorders.pl
@@ -76,6 +76,19 @@ unless ($delay =~ /^\d{1,3}$/) {
 	$delay = 30;	#default value for delay
 }
 
+if ($op and $op eq "send_alert"){
+    my @ordernums = $input->param("claim_for");# FIXME: Fallback values?
+    eval {
+        SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") );    # FIXME: Fallback value?
+        AddClaim ( $_ ) for @ordernums;
+    };
+    if ( $@ ) {
+        $template->param(error_claim => $@);
+    } else {
+        $template->param(info_claim => "Emails have been sent");
+    }
+}
+
 my %supplierlist = GetBooksellersWithLateOrders($delay);
 my (@sloopy);	# supplier loop
 foreach (keys %supplierlist){
@@ -100,11 +113,6 @@ foreach (keys %$letters){
 }
 $template->param(letters=>\@letters) if (@letters);
 
-if ($op and $op eq "send_alert"){
-	my @ordernums = $input->param("claim_for");									# FIXME: Fallback values?
-	SendAlerts('claimacquisition',\@ordernums,$input->param("letter_code"));	# FIXME: Fallback value?
-}
-
 $template->param(ERROR_LOOP => \@errors) if (@errors);
 $template->param(
 	lateorders => \@lateorders,
diff --git a/installer/data/mysql/en/mandatory/sample_notices.sql b/installer/data/mysql/en/mandatory/sample_notices.sql
index 689fa0f..0c9e860 100644
--- a/installer/data/mysql/en/mandatory/sample_notices.sql
+++ b/installer/data/mysql/en/mandatory/sample_notices.sql
@@ -1,6 +1,6 @@
 INSERT INTO `letter` (module, code, name, title, content) 
 VALUES ('circulation','ODUE','Overdue Notice','Item Overdue','Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\nAccording to our current records, you have items that are overdue.Your library does not charge late fines, but please return or renew them at the branch below as soon as possible.\n\n<<branches.branchname>>\n<<branches.branchaddress1>>\n<<branches.branchaddress2>> <<branches.branchaddress3>>\nPhone: <<branches.branchphone>>\nFax: <<branches.branchfax>>\nEmail: <<branches.branchemail>>\n\nIf you have registered a password with the library, and you have a renewal available, you may renew online. If an item becomes more than 30 days overdue, you will be unable to use your library card until the item is returned.\n\nThe following item(s) is/are currently overdue:\n\n<item>"<<biblio.title>>" by <<biblio.author>>, <<items.itemcallnumber>>, Barcode: <<items.barcode>> Fine: <fine>GBP</fine></item>\n\nThank-you for your prompt attention to this matter.\n\n<<branches.branchname
-('claimacquisition','ACQCLAIM','Acquisition Claim','Item Not Received','<<aqbooksellers.name>>\r\n<<aqbooksellers.address1>>\r\n<<aqbooksellers.address2>>\r\n<<aqbooksellers.address3>>\r\n<<aqbooksellers.address4>>\r\n<<aqbooksellers.phone>>\r\n\r\nOrdernumber <<aqorders.ordernumber>> (<<aqorders.title>>) (<<aqorders.quantity>> ordered) ($<<aqorders.listprice>> each) has not been received.'),
+('claimacquisition','ACQCLAIM','Acquisition Claim','Item Not Received','<<aqbooksellers.name>>\r\n<<aqbooksellers.address1>>\r\n<<aqbooksellers.address2>>\r\n<<aqbooksellers.address3>>\r\n<<aqbooksellers.address4>>\r\n<<aqbooksellers.phone>>\r\n\r\nOrdernumber <<aqorders.ordernumber>> (<<biblio.title>>) (<<aqorders.quantity>> ordered) ($<<aqorders.listprice>> each) has not been received.'),
 ('serial','RLIST','Routing List','Serial is now available','<<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nThe following issue is now available:\r\n\r\n<<biblio.title>>, <<biblio.author>> (<<items.barcode>>)\r\n\r\nPlease pick it up at your convenience.'),
 ('members','ACCTDETAILS','Account Details Template - DEFAULT','Your new Koha account details.','Hello <<borrowers.title>> <<borrowers.firstname>> <<borrowers.surname>>.\r\n\r\nYour new Koha account details are:\r\n\r\nUser:  <<borrowers.userid>>\r\nPassword: <<borrowers.password>>\r\n\r\nIf you have any problems or questions regarding your account, please contact your Koha Administrator.\r\n\r\nThank you,\r\nKoha Administrator\r\nkohaadmin at yoursite.org'), 
 ('circulation','DUE','Item Due Reminder','Item Due Reminder','Dear <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nThe following item is now due:\r\n\r\n<<biblio.title>>, <<biblio.author>> (<<items.barcode>>)'), 
diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql b/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql
index 977e59d..09dc641 100644
--- a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql
+++ b/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql
@@ -2,7 +2,7 @@ INSERT IGNORE INTO `letter`
 (module, code, name, title, content)
 VALUES
 ('circulation','ODUE','Overdue Notice','Item Overdue','Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\nAccording to our current records, you have items that are overdue.Your library does not charge late fines, but please return or renew them at the branch below as soon as possible.\n\n<<branches.branchname>>\n<<branches.branchaddress1>>\n<<branches.branchaddress2>> <<branches.branchaddress3>>\nPhone: <<branches.branchphone>>\nFax: <<branches.branchfax>>\nEmail: <<branches.branchemail>>\n\nIf you have registered a password with the library, and you have a renewal available, you may renew online. If an item becomes more than 30 days overdue, you will be unable to use your library card until the item is returned.\n\nThe following item(s) is/are currently overdue:\n\n<item>"<<biblio.title>>" by <<biblio.author>>, <<items.itemcallnumber>>, Barcode: <<items.barcode>> Fine: <fine>GBP</fine></item>\n\nThank-you for your prompt attention to this matter.\n\n<<branches.branchname>> Staf
-('claimacquisition','ACQCLAIM','Acquisition Claim','Item Not Received','<<aqbooksellers.name>>\r\n<<aqbooksellers.address1>>\r\n<<aqbooksellers.address2>>\r\n<<aqbooksellers.address3>>\r\n<<aqbooksellers.address4>>\r\n<<aqbooksellers.phone>>\r\n\r\nOrdernumber <<aqorders.ordernumber>> (<<aqorders.title>>) (<<aqorders.quantity>> ordered) ($<<aqorders.listprice>> each) has not been received.'),
+('claimacquisition','ACQCLAIM','Acquisition Claim','Item Not Received','<<aqbooksellers.name>>\r\n<<aqbooksellers.address1>>\r\n<<aqbooksellers.address2>>\r\n<<aqbooksellers.address3>>\r\n<<aqbooksellers.address4>>\r\n<<aqbooksellers.phone>>\r\n\r\nOrdernumber <<aqorders.ordernumber>> (<<biblio.title>>) (<<aqorders.quantity>> ordered) ($<<aqorders.listprice>> each) has not been received.'),
 ('serial','RLIST','Routing List','Serial is now available','<<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nThe following issue is now available:\r\n\r\n<<biblio.title>>, <<biblio.author>> (<<items.barcode>>)\r\n\r\nPlease pick it up at your convenience.'),
 ('members','ACCTDETAILS','Account Details Template - DEFAULT','Your new Koha account details.','Hello <<borrowers.title>> <<borrowers.firstname>> <<borrowers.surname>>.\r\n\r\nYour new Koha account details are:\r\n\r\nUser:  <<borrowers.userid>>\r\nPassword: <<borrowers.password>>\r\n\r\nIf you have any problems or questions regarding your account, please contact your Koha Administrator.\r\n\r\nThank you,\r\nKoha Administrator\r\nkohaadmin at yoursite.org'),
 ('circulation','DUE','Item Due Reminder','Item Due Reminder','Dear <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nThe following item is now due:\r\n\r\n<<biblio.title>>, <<biblio.author>> (<<items.barcode>>)'),
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index 452173d..c79c4b9 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -2631,6 +2631,8 @@ CREATE TABLE `aqorders` (
   `sort1_authcat` varchar(10) default NULL,
   `sort2_authcat` varchar(10) default NULL,
   `uncertainprice` tinyint(1),
+  `claims_count` int(11) default 0,
+  `claimed_date` date default NULL,
   PRIMARY KEY  (`ordernumber`),
   KEY `basketno` (`basketno`),
   KEY `biblionumber` (`biblionumber`),
diff --git a/installer/data/mysql/pl-PL/mandatory/sample_notices.sql b/installer/data/mysql/pl-PL/mandatory/sample_notices.sql
index 6be2eb8..287730a 100644
--- a/installer/data/mysql/pl-PL/mandatory/sample_notices.sql
+++ b/installer/data/mysql/pl-PL/mandatory/sample_notices.sql
@@ -2,7 +2,7 @@ INSERT INTO `letter` (module, code, name, title, content)
 VALUES 
 ('circulation','ODUE','Overdue Notice',
 'Item Overdue','Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\nAccording to our current records, you have items that are overdue.Your library does not charge late fines, but please return or renew them at the branch below as soon as possible.\n\n<<branches.branchname>>\n<<branches.branchaddress1>>\n<<branches.branchaddress2>> <<branches.branchaddress3>>\nPhone: <<branches.branchphone>>\nFax: <<branches.branchfax>>\nEmail: <<branches.branchemail>>\n\nIf you have registered a password with the library, and you have a renewal available, you may renew online. If an item becomes more than 30 days overdue, you will be unable to use your library card until the item is returned.\n\nThe following item(s) is/are currently overdue:\n\n<item>"<<biblio.title>>" by <<biblio.author>>, <<items.itemcallnumber>>, Barcode: <<items.barcode>> Fine: <fine>GBP</fine></item>\n\nThank-you for your prompt attention to this matter.\n\n<<branches.branchname>> Staff\n'),
-('claimacquisition','ACQCLAIM','Acquisition Claim','Item Not Received','<<aqbooksellers.name>>\r\n<<aqbooksellers.address1>>\r\n<<aqbooksellers.address2>>\r\n<<aqbooksellers.address3>>\r\n<<aqbooksellers.address4>>\r\n<<aqbooksellers.phone>>\r\n\r\nOrdernumber <<aqorders.ordernumber>> (<<aqorders.title>>) (<<aqorders.quantity>> ordered) ($<<aqorders.listprice>> each) has not been received.'),
+('claimacquisition','ACQCLAIM','Acquisition Claim','Item Not Received','<<aqbooksellers.name>>\r\n<<aqbooksellers.address1>>\r\n<<aqbooksellers.address2>>\r\n<<aqbooksellers.address3>>\r\n<<aqbooksellers.address4>>\r\n<<aqbooksellers.phone>>\r\n\r\nOrdernumber <<aqorders.ordernumber>> (<<biblio.title>>) (<<aqorders.quantity>> ordered) ($<<aqorders.listprice>> each) has not been received.'),
 ('serial','RLIST','Routing List','Serial is now available','<<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nThe following issue is now available:\r\n\r\n<<biblio.title>>, <<biblio.author>> (<<items.barcode>>)\r\n\r\nPlease pick it up at your convenience.'),
 ('members','ACCTDETAILS','Account Details Template - DEFAULT','Your new Koha account details.','Hello <<borrowers.title>> <<borrowers.firstname>> <<borrowers.surname>>.\r\n\r\nYour new Koha account details are:\r\n\r\nUser:  <<borrowers.userid>>\r\nPassword: <<borrowers.password>>\r\n\r\nIf you have any problems or questions regarding your account, please contact your Koha Administrator.\r\n\r\nThank you,\r\nKoha Administrator\r\nkohaadmin at yoursite.org'), 
 ('circulation','DUE','Item Due Reminder','Item Due Reminder','Dear <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nThe following item is now due:\r\n\r\n<<biblio.title>>, <<biblio.author>> (<<items.barcode>>)'), 
diff --git a/installer/data/mysql/ru-RU/mandatory/sample_notices.sql b/installer/data/mysql/ru-RU/mandatory/sample_notices.sql
index 689fa0f..0c9e860 100644
--- a/installer/data/mysql/ru-RU/mandatory/sample_notices.sql
+++ b/installer/data/mysql/ru-RU/mandatory/sample_notices.sql
@@ -1,6 +1,6 @@
 INSERT INTO `letter` (module, code, name, title, content) 
 VALUES ('circulation','ODUE','Overdue Notice','Item Overdue','Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\nAccording to our current records, you have items that are overdue.Your library does not charge late fines, but please return or renew them at the branch below as soon as possible.\n\n<<branches.branchname>>\n<<branches.branchaddress1>>\n<<branches.branchaddress2>> <<branches.branchaddress3>>\nPhone: <<branches.branchphone>>\nFax: <<branches.branchfax>>\nEmail: <<branches.branchemail>>\n\nIf you have registered a password with the library, and you have a renewal available, you may renew online. If an item becomes more than 30 days overdue, you will be unable to use your library card until the item is returned.\n\nThe following item(s) is/are currently overdue:\n\n<item>"<<biblio.title>>" by <<biblio.author>>, <<items.itemcallnumber>>, Barcode: <<items.barcode>> Fine: <fine>GBP</fine></item>\n\nThank-you for your prompt attention to this matter.\n\n<<branches.branchname
-('claimacquisition','ACQCLAIM','Acquisition Claim','Item Not Received','<<aqbooksellers.name>>\r\n<<aqbooksellers.address1>>\r\n<<aqbooksellers.address2>>\r\n<<aqbooksellers.address3>>\r\n<<aqbooksellers.address4>>\r\n<<aqbooksellers.phone>>\r\n\r\nOrdernumber <<aqorders.ordernumber>> (<<aqorders.title>>) (<<aqorders.quantity>> ordered) ($<<aqorders.listprice>> each) has not been received.'),
+('claimacquisition','ACQCLAIM','Acquisition Claim','Item Not Received','<<aqbooksellers.name>>\r\n<<aqbooksellers.address1>>\r\n<<aqbooksellers.address2>>\r\n<<aqbooksellers.address3>>\r\n<<aqbooksellers.address4>>\r\n<<aqbooksellers.phone>>\r\n\r\nOrdernumber <<aqorders.ordernumber>> (<<biblio.title>>) (<<aqorders.quantity>> ordered) ($<<aqorders.listprice>> each) has not been received.'),
 ('serial','RLIST','Routing List','Serial is now available','<<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nThe following issue is now available:\r\n\r\n<<biblio.title>>, <<biblio.author>> (<<items.barcode>>)\r\n\r\nPlease pick it up at your convenience.'),
 ('members','ACCTDETAILS','Account Details Template - DEFAULT','Your new Koha account details.','Hello <<borrowers.title>> <<borrowers.firstname>> <<borrowers.surname>>.\r\n\r\nYour new Koha account details are:\r\n\r\nUser:  <<borrowers.userid>>\r\nPassword: <<borrowers.password>>\r\n\r\nIf you have any problems or questions regarding your account, please contact your Koha Administrator.\r\n\r\nThank you,\r\nKoha Administrator\r\nkohaadmin at yoursite.org'), 
 ('circulation','DUE','Item Due Reminder','Item Due Reminder','Dear <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nThe following item is now due:\r\n\r\n<<biblio.title>>, <<biblio.author>> (<<items.barcode>>)'), 
diff --git a/installer/data/mysql/ru-RU/optional/sample_notices.sql b/installer/data/mysql/ru-RU/optional/sample_notices.sql
index 4f2001e..d6537e1 100644
--- a/installer/data/mysql/ru-RU/optional/sample_notices.sql
+++ b/installer/data/mysql/ru-RU/optional/sample_notices.sql
@@ -5,7 +5,7 @@ INSERT INTO `letter`
 VALUES
 ('circulation','ODUE','Уведомление о просрочке','Единица прострочена','Любезный <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nПо нашим нынешним записям, у Вас есть простроченные экземпляры. Ваша библиотека не взимает штрафы за опоздание, но, пожалуйста, поверните или обновите их как можно скорее.\r\n\r\n<<branches.branchname>><<branches.branchaddress1>><<branches.branchaddress2>><<branches.branchaddress3>><<branches.branchphone>><<branches.branchfax>><<branches.branchemail>>Если Ð’Ñ‹ зарегистрировали пароль в библиотеке, вы можете использовать его с вашим номером библиотечного билета для продолжения онлайн. Если экземпляр имеет просрочки более чеÐ
 
-('claimacquisition','ACQCLAIM','Требование приобретения','Экземпляр не получено','<<aqbooksellers.name>>\r\n<<aqbooksellers.address1>>\r\n<<aqbooksellers.address2>>\r\n<<aqbooksellers.address3>>\r\n<<aqbooksellers.address4>>\r\n<<aqbooksellers.phone>>\r\n\r\nНомер заказа <<aqorders.ordernumber>> (<<aqorders.title>>) (<<aqorders.quantity>> каждый) получено не было.'),
+('claimacquisition','ACQCLAIM','Требование приобретения','Экземпляр не получено','<<aqbooksellers.name>>\r\n<<aqbooksellers.address1>>\r\n<<aqbooksellers.address2>>\r\n<<aqbooksellers.address3>>\r\n<<aqbooksellers.address4>>\r\n<<aqbooksellers.phone>>\r\n\r\nНомер заказа <<aqorders.ordernumber>> (<<biblio.title>>) (<<aqorders.quantity>> каждый) получено не было.'),
 
 ('serial','RLIST','Список скерування','Сериальные издания уже доступное','<<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nСледующий выпуск уже доступен:\r\n\r\n<<items.content>>\r\n\r\nПросьба забрать его в любое удобное для Вас время.'),
 
diff --git a/installer/data/mysql/uk-UA/mandatory/sample_notices.sql b/installer/data/mysql/uk-UA/mandatory/sample_notices.sql
index 358205b..dc5a54d 100644
--- a/installer/data/mysql/uk-UA/mandatory/sample_notices.sql
+++ b/installer/data/mysql/uk-UA/mandatory/sample_notices.sql
@@ -1,6 +1,6 @@
 INSERT INTO `letter` (module, code, name, title, content) 
 VALUES ('circulation','ODUE','Overdue Notice','Item Overdue','Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\nAccording to our current records, you have items that are overdue.Your library does not charge late fines, but please return or renew them at the branch below as soon as possible.\n\n<<branches.branchname>>\n<<branches.branchaddress1>>\n<<branches.branchaddress2>> <<branches.branchaddress3>>\nPhone: <<branches.branchphone>>\nFax: <<branches.branchfax>>\nEmail: <<branches.branchemail>>\n\nIf you have registered a password with the library, and you have a renewal available, you may renew online. If an item becomes more than 30 days overdue, you will be unable to use your library card until the item is returned.\n\nThe following item(s) is/are currently overdue:\n\n<item>"<<biblio.title>>" by <<biblio.author>>, <<items.itemcallnumber>>, Barcode: <<items.barcode>> Fine: <fine>GBP</fine></item>\n\nThank-you for your prompt attention to this matter.\n\n<<branches.branchname
-('claimacquisition','ACQCLAIM','Acquisition Claim','Item Not Received','<<aqbooksellers.name>>\r\n<<aqbooksellers.address1>>\r\n<<aqbooksellers.address2>>\r\n<<aqbooksellers.address3>>\r\n<<aqbooksellers.address4>>\r\n<<aqbooksellers.phone>>\r\n\r\nOrdernumber <<aqorders.ordernumber>> (<<aqorders.title>>) (<<aqorders.quantity>> ordered) ($<<aqorders.listprice>> each) has not been received.'),
+('claimacquisition','ACQCLAIM','Acquisition Claim','Item Not Received','<<aqbooksellers.name>>\r\n<<aqbooksellers.address1>>\r\n<<aqbooksellers.address2>>\r\n<<aqbooksellers.address3>>\r\n<<aqbooksellers.address4>>\r\n<<aqbooksellers.phone>>\r\n\r\nOrdernumber <<aqorders.ordernumber>> (<<biblio.title>>) (<<aqorders.quantity>> ordered) ($<<aqorders.listprice>> each) has not been received.'),
 ('serial','RLIST','Routing List','Serial is now available','<<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nThe following issue is now available:\r\n\r\n<<biblio.title>>, <<biblio.author>> (<<items.barcode>>)\r\n\r\nPlease pick it up at your convenience.'),
 ('members','ACCTDETAILS','Account Details Template - DEFAULT','Your new Koha account details.','Hello <<borrowers.title>> <<borrowers.firstname>> <<borrowers.surname>>.\r\n\r\nYour new Koha account details are:\r\n\r\nUser:  <<borrowers.userid>>\r\nPassword: <<borrowers.password>>\r\n\r\nIf you have any problems or questions regarding your account, please contact your Koha Administrator.\r\n\r\nThank you,\r\nKoha Administrator\r\nkohaadmin at yoursite.org'), 
 ('circulation','DUE','Item Due Reminder','Item Due Reminder','Dear <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nThe following item is now due:\r\n\r\n<<biblio.title>>, <<biblio.author>> (<<items.barcode>>)'), 
diff --git a/installer/data/mysql/uk-UA/optional/sample_notices.sql b/installer/data/mysql/uk-UA/optional/sample_notices.sql
index 6df324b..0e1e1f4 100644
--- a/installer/data/mysql/uk-UA/optional/sample_notices.sql
+++ b/installer/data/mysql/uk-UA/optional/sample_notices.sql
@@ -5,7 +5,7 @@ INSERT INTO `letter`
 VALUES
 ('circulation','ODUE','Повідомлення про прострочення','Одиниця прострочена','Добродію <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nПо нашим нинішнім записам, у Вас є прострочені екземпляри. Ваша бібліотека не стягує штрафи за запізнення, але, будь ласка, поверніть або оновіть їх як можна швидше.\r\n\r\n<<branches.branchname>><<branches.branchaddress1>><<branches.branchaddress2>><<branches.branchaddress3>><<branches.branchphone>><<branches.branchfax>><<branches.branchemail>>Якщо Ви зареєстрували пароль у бібліотеці, ви можете використовувати його з Вашим номером бібліотечного квитка для продовження онлайн. Якщо примірник має прострочення більш н
 
-('claimacquisition','ACQCLAIM','Вимога придбання','Примірник не отримано','<<aqbooksellers.name>>\r\n<<aqbooksellers.address1>>\r\n<<aqbooksellers.address2>>\r\n<<aqbooksellers.address3>>\r\n<<aqbooksellers.address4>>\r\n<<aqbooksellers.phone>>\r\n\r\nНомер замовлення <<aqorders.ordernumber>> (<<aqorders.title>>) (<<aqorders.quantity>> замовлено) (<<aqorders.listprice>> кожний) отримано не було.'),
+('claimacquisition','ACQCLAIM','Вимога придбання','Примірник не отримано','<<aqbooksellers.name>>\r\n<<aqbooksellers.address1>>\r\n<<aqbooksellers.address2>>\r\n<<aqbooksellers.address3>>\r\n<<aqbooksellers.address4>>\r\n<<aqbooksellers.phone>>\r\n\r\nНомер замовлення <<aqorders.ordernumber>> (<<biblio.title>>) (<<aqorders.quantity>> замовлено) (<<aqorders.listprice>> кожний) отримано не було.'),
 
 ('serial','RLIST','Список направления','Серіальне видання вже доступне','<<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nНаступний випуск вже доступний:\r\n\r\n<<items.content>>\r\n\r\nПрохання забрати його в будь-який зручний для Вас час.'),
 
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index 9ae0060..f46d33b 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -4571,6 +4571,12 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
     SetVersion($DBversion);
 }
 
+$DBversion = "3.06.00.XXX";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+    $dbh->do("ALTER TABLE `aqorders` ADD COLUMN `claims_count` INT(11)  DEFAULT 0, ADD COLUMN `claimed_date` DATE  DEFAULT NULL AFTER `claims_count`");
+    print "Upgrade to $DBversion done (Add claims_count and claimed_date fields in aqorders table)\n";
+    SetVersion($DBversion);
+}
 
 =head1 FUNCTIONS
 
diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
index 7b38062..7557f58 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
+++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
@@ -2080,4 +2080,12 @@ div.pager input.pagedisplay {
 	background-color : transparent;
 	font-weight: bold;
 	text-align : center;
-}
\ No newline at end of file
+}
+
+div.info {
+   border : 2px dashed #990000;
+   background-color : #99FFCC;
+   padding : .5em;
+   margin : 1em;
+}
+
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt
index 1e64e1f..545d9c7 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt
@@ -1,6 +1,20 @@
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha › Acquisitions › Late orders</title>
 [% INCLUDE 'doc-head-close.inc' %]
+<script type="text/javascript">
+//<![CDATA[
+$(document).ready(function() {
+    $("input:checkbox[name=claim_for]").click(function(){
+        var supplierid = $(this).attr('supplierid');
+        if ( $("input:checkbox[name=claim_for]:checked").length > 0) {
+            $("input:checkbox[name=claim_for][supplierid!="+supplierid+"]").attr('disabled', true);
+        } else {
+            $("input:checkbox[name=claim_for]").attr('disabled', false);
+        }
+    });
+});
+//]]>
+</script>
 </head>
 <body>
 [% INCLUDE 'header.inc' %]
@@ -17,6 +31,12 @@
 <h1>[% IF ( Supplier ) %][% Supplier %] : [% END %]Late orders</h1>
 <div id="acqui_lateorders">
 
+[% IF error_claim %]
+    <div class="error">[% error_claim %]</div>
+[% END %]
+[% IF info_claim %]
+    <div class="info">[% info_claim %]</div>
+[% END %]
 [% IF ( lateorders ) %]
 <form action="lateorders.pl" name="claim" method="post">
   <input type="hidden" name="op" value="send_alert" />
@@ -35,12 +55,20 @@
             <th>Information</th>
             <th>Total cost</th>
             <th>Basket</th>
-            <th> </th>
+            <th>claims count</th>
+            <th>claimed date</th>
+            <!-- TMPL_IF name="Supplier" -->
+            [% IF Supplier %]
+                <th><input type="checkbox" id="checkAll"></th>
+            [% ELSE %]
+                <th></th>
+            [% END %]
         </tr>
     [% FOREACH lateorder IN lateorders %]
         [% UNLESS ( loop.odd ) %]<tr class="highlight">
         [% ELSE %]<tr>[% END %]
             <td>
+                ([% lateorder.supplierid %])
                 [% lateorder.orderdate %]
                 ([% lateorder.latesince %] days)
             </td>
@@ -69,8 +97,13 @@
                  </p>
                  <p title="branch">[% lateorder.branch %]</p>
             </td>
+            <td>[% lateorder.claims_count %]</td>
+            <td>[% lateorder.claimed_date %]</td>
             <td>
-                <input type="checkbox" name="claim_for" value="[% lateorder.ordernumber %]" />
+                [% UNLESS lateorder.budget_lock %]
+                    <input type="checkbox" name="claim_for" value="[% lateorder.ordernumber %]"  supplierid="[% lateorder.supplierid %]"/>
+                [% END %]
+             </td>
             </td>
         </tr>
         [% END %]
@@ -79,6 +112,8 @@
             <th colspan="2"> </th>
             <th>[% total %]</th>
             <th> </th>
+            <th> </th>
+            <th> </th>
             <td>
                 <input type="submit" value="Claim Order" />
             </td>
-- 
1.7.7.3




More information about the Patches mailing list