View | Details | Raw Unified | Return to bug 10021
Collapse All | Expand All

(-)a/C4/Overdues.pm (-93 / +4 lines)
Lines 55-64 BEGIN { Link Here
55
      &UpdateFine
55
      &UpdateFine
56
      &GetFine
56
      &GetFine
57
      &get_chargeable_units
57
      &get_chargeable_units
58
      &CheckItemNotify
59
      &GetOverduesForBranch
58
      &GetOverduesForBranch
60
      &RemoveNotifyLine
61
      &AddNotifyLine
62
      &GetOverdueMessageTransportTypes
59
      &GetOverdueMessageTransportTypes
63
      &parse_overdues_letter
60
      &parse_overdues_letter
64
    );
61
    );
Lines 808-834 sub GetBranchcodesWithOverdueRules { Link Here
808
    return @$branchcodes;
805
    return @$branchcodes;
809
}
806
}
810
807
811
=head2 CheckItemNotify
812
813
Sql request to check if the document has alreday been notified
814
this function is not exported, only used with GetOverduesForBranch
815
816
=cut
817
818
sub CheckItemNotify {
819
    my ($notify_id,$notify_level,$itemnumber) = @_;
820
    my $dbh = C4::Context->dbh;
821
    my $sth = $dbh->prepare("
822
    SELECT COUNT(*)
823
     FROM notifys
824
    WHERE notify_id    = ?
825
     AND  notify_level = ? 
826
     AND  itemnumber   = ? ");
827
    $sth->execute($notify_id,$notify_level,$itemnumber);
828
    my $notified = $sth->fetchrow;
829
    return ($notified);
830
}
831
832
=head2 GetOverduesForBranch
808
=head2 GetOverduesForBranch
833
809
834
Sql request for display all information for branchoverdues.pl
810
Sql request for display all information for branchoverdues.pl
Lines 881-958 sub GetOverduesForBranch { Link Here
881
      AND (issues.branchcode =  ?   )
857
      AND (issues.branchcode =  ?   )
882
      AND (issues.date_due  < NOW())
858
      AND (issues.date_due  < NOW())
883
    ";
859
    ";
884
    my @getoverdues;
885
    my $i = 0;
886
    my $sth;
887
    if ($location) {
860
    if ($location) {
888
        $sth = $dbh->prepare("$select AND items.location = ? ORDER BY borrowers.surname, borrowers.firstname");
861
        my $q = "$select AND items.location = ? ORDER BY borrowers.surname, borrowers.firstname";
889
        $sth->execute($branch, $location);
862
        return @{ $dbh->selectall_arrayref($q, { Slice => {} }, $branch, $location ) };
890
    } else {
863
    } else {
891
        $sth = $dbh->prepare("$select ORDER BY borrowers.surname, borrowers.firstname");
864
        my $q = "$select ORDER BY borrowers.surname, borrowers.firstname";
892
        $sth->execute($branch);
865
        return @{ $dbh->selectall_arrayref($q, { Slice => {} }, $branch ) };
893
    }
866
    }
894
    while ( my $data = $sth->fetchrow_hashref ) {
895
    #check if the document has already been notified
896
        my $countnotify = CheckItemNotify($data->{'notify_id'}, $data->{'notify_level'}, $data->{'itemnumber'});
897
        if ($countnotify eq '0') {
898
            $getoverdues[$i] = $data;
899
            $i++;
900
        }
901
    }
902
    return (@getoverdues);
903
}
904
905
906
=head2 AddNotifyLine
907
908
    &AddNotifyLine($borrowernumber, $itemnumber, $overduelevel, $method, $notifyId)
909
910
Create a line into notify, if the method is phone, the notification_send_date is implemented to
911
912
=cut
913
914
sub AddNotifyLine {
915
    my ( $borrowernumber, $itemnumber, $overduelevel, $method, $notifyId ) = @_;
916
    my $dbh = C4::Context->dbh;
917
    if ( $method eq "phone" ) {
918
        my $sth = $dbh->prepare(
919
            "INSERT INTO notifys (borrowernumber,itemnumber,notify_date,notify_send_date,notify_level,method,notify_id)
920
        VALUES (?,?,now(),now(),?,?,?)"
921
        );
922
        $sth->execute( $borrowernumber, $itemnumber, $overduelevel, $method,
923
            $notifyId );
924
    }
925
    else {
926
        my $sth = $dbh->prepare(
927
            "INSERT INTO notifys (borrowernumber,itemnumber,notify_date,notify_level,method,notify_id)
928
        VALUES (?,?,now(),?,?,?)"
929
        );
930
        $sth->execute( $borrowernumber, $itemnumber, $overduelevel, $method,
931
            $notifyId );
932
    }
933
    return 1;
934
}
935
936
=head2 RemoveNotifyLine
937
938
    &RemoveNotifyLine( $borrowernumber, $itemnumber, $notify_date );
939
940
Cancel a notification
941
942
=cut
943
944
sub RemoveNotifyLine {
945
    my ( $borrowernumber, $itemnumber, $notify_date ) = @_;
946
    my $dbh = C4::Context->dbh;
947
    my $sth = $dbh->prepare(
948
        "DELETE FROM notifys 
949
            WHERE
950
            borrowernumber=?
951
            AND itemnumber=?
952
            AND notify_date=?"
953
    );
954
    $sth->execute( $borrowernumber, $itemnumber, $notify_date );
955
    return 1;
956
}
867
}
957
868
958
=head2 GetOverdueMessageTransportTypes
869
=head2 GetOverdueMessageTransportTypes
(-)a/Koha/Schema/Result/Notify.pm (-94 lines)
Lines 1-94 Link Here
1
use utf8;
2
package Koha::Schema::Result::Notify;
3
4
# Created by DBIx::Class::Schema::Loader
5
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7
=head1 NAME
8
9
Koha::Schema::Result::Notify
10
11
=cut
12
13
use strict;
14
use warnings;
15
16
use base 'DBIx::Class::Core';
17
18
=head1 TABLE: C<notifys>
19
20
=cut
21
22
__PACKAGE__->table("notifys");
23
24
=head1 ACCESSORS
25
26
=head2 notify_id
27
28
  data_type: 'integer'
29
  default_value: 0
30
  is_nullable: 0
31
32
=head2 borrowernumber
33
34
  data_type: 'integer'
35
  default_value: 0
36
  is_nullable: 0
37
38
=head2 itemnumber
39
40
  data_type: 'integer'
41
  default_value: 0
42
  is_nullable: 0
43
44
=head2 notify_date
45
46
  data_type: 'date'
47
  datetime_undef_if_invalid: 1
48
  is_nullable: 1
49
50
=head2 notify_send_date
51
52
  data_type: 'date'
53
  datetime_undef_if_invalid: 1
54
  is_nullable: 1
55
56
=head2 notify_level
57
58
  data_type: 'integer'
59
  default_value: 0
60
  is_nullable: 0
61
62
=head2 method
63
64
  data_type: 'varchar'
65
  default_value: (empty string)
66
  is_nullable: 0
67
  size: 20
68
69
=cut
70
71
__PACKAGE__->add_columns(
72
  "notify_id",
73
  { data_type => "integer", default_value => 0, is_nullable => 0 },
74
  "borrowernumber",
75
  { data_type => "integer", default_value => 0, is_nullable => 0 },
76
  "itemnumber",
77
  { data_type => "integer", default_value => 0, is_nullable => 0 },
78
  "notify_date",
79
  { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
80
  "notify_send_date",
81
  { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
82
  "notify_level",
83
  { data_type => "integer", default_value => 0, is_nullable => 0 },
84
  "method",
85
  { data_type => "varchar", default_value => "", is_nullable => 0, size => 20 },
86
);
87
88
89
# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21
90
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:sQc1HF4rGwsMBh6uFNKUnQ
91
92
93
# You can replace this text with custom content, and it will be preserved on regeneration
94
1;
(-)a/circ/branchoverdues.pl (-14 / +1 lines)
Lines 22-28 use C4::Context; Link Here
22
use CGI qw ( -utf8 );
22
use CGI qw ( -utf8 );
23
use C4::Output;
23
use C4::Output;
24
use C4::Auth;
24
use C4::Auth;
25
use C4::Overdues;    # AddNotifyLine
25
use C4::Overdues;
26
use C4::Biblio;
26
use C4::Biblio;
27
use C4::Koha;
27
use C4::Koha;
28
use C4::Debug;
28
use C4::Debug;
Lines 34-40 use Data::Dumper; Link Here
34
34
35
 this module is a new interface, allow to the librarian to check all items on overdues (based on the acountlines type 'FU' )
35
 this module is a new interface, allow to the librarian to check all items on overdues (based on the acountlines type 'FU' )
36
 this interface is filtered by branches (automatically), and by location (optional) ....
36
 this interface is filtered by branches (automatically), and by location (optional) ....
37
 all informations are stocked in the notifys BDD
38
37
39
 FIXME for this time, we have only four methods to notify :
38
 FIXME for this time, we have only four methods to notify :
40
 	- mail : work with a batch programm
39
 	- mail : work with a batch programm
Lines 84-101 my $location = $input->param('location'); Link Here
84
# FIXME: better check that borrowernumber is defined and valid.
83
# FIXME: better check that borrowernumber is defined and valid.
85
# FIXME: same for itemnumber and other variables passed in here.
84
# FIXME: same for itemnumber and other variables passed in here.
86
85
87
# now create the line in bdd (notifys)
88
if ( $input->param('action') eq 'add' ) {
89
    my $addnotify =
90
      AddNotifyLine( $borrowernumber, $itemnumber, $overduelevel, $method,
91
        $notifyId )    # FIXME: useless variable, no TMPL code for "action" exists.;
92
}
93
elsif ( $input->param('action') eq 'remove' ) {
94
    my $notify_date  = $input->param('notify_date');
95
    my $removenotify =
96
      RemoveNotifyLine( $borrowernumber, $itemnumber, $notify_date );    # FIXME: useless variable, no TMPL code for "action" exists.
97
}
98
99
my @overduesloop;
86
my @overduesloop;
100
my @getoverdues = GetOverduesForBranch( $default, $location );
87
my @getoverdues = GetOverduesForBranch( $default, $location );
101
$debug and warn "HERE : $default / $location" . Dumper(@getoverdues);
88
$debug and warn "HERE : $default / $location" . Dumper(@getoverdues);
(-)a/installer/data/mysql/kohastructure.sql (-16 lines)
Lines 1281-1301 CREATE TABLE `need_merge_authorities` ( -- keeping track of authority records st Link Here
1281
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1281
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1282
1282
1283
--
1283
--
1284
-- Table structure for table `notifys`
1285
--
1286
1287
DROP TABLE IF EXISTS `notifys`;
1288
CREATE TABLE `notifys` (
1289
  `notify_id` int(11) NOT NULL default 0,
1290
  `borrowernumber` int(11) NOT NULL default 0,
1291
  `itemnumber` int(11) NOT NULL default 0,
1292
  `notify_date` date default NULL,
1293
  `notify_send_date` date default NULL,
1294
  `notify_level` int(1) NOT NULL default 0,
1295
  `method` varchar(20) NOT NULL default ''
1296
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1297
1298
--
1299
-- Table structure for table `oai_sets`
1284
-- Table structure for table `oai_sets`
1300
--
1285
--
1301
1286
1302
- 

Return to bug 10021