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 792-818 sub GetBranchcodesWithOverdueRules { Link Here
792
    return @$branchcodes;
789
    return @$branchcodes;
793
}
790
}
794
791
795
=head2 CheckItemNotify
796
797
Sql request to check if the document has alreday been notified
798
this function is not exported, only used with GetOverduesForBranch
799
800
=cut
801
802
sub CheckItemNotify {
803
    my ($notify_id,$notify_level,$itemnumber) = @_;
804
    my $dbh = C4::Context->dbh;
805
    my $sth = $dbh->prepare("
806
    SELECT COUNT(*)
807
     FROM notifys
808
    WHERE notify_id    = ?
809
     AND  notify_level = ? 
810
     AND  itemnumber   = ? ");
811
    $sth->execute($notify_id,$notify_level,$itemnumber);
812
    my $notified = $sth->fetchrow;
813
    return ($notified);
814
}
815
816
=head2 GetOverduesForBranch
792
=head2 GetOverduesForBranch
817
793
818
Sql request for display all information for branchoverdues.pl
794
Sql request for display all information for branchoverdues.pl
Lines 865-942 sub GetOverduesForBranch { Link Here
865
      AND (issues.branchcode =  ?   )
841
      AND (issues.branchcode =  ?   )
866
      AND (issues.date_due  < NOW())
842
      AND (issues.date_due  < NOW())
867
    ";
843
    ";
868
    my @getoverdues;
869
    my $i = 0;
870
    my $sth;
871
    if ($location) {
844
    if ($location) {
872
        $sth = $dbh->prepare("$select AND items.location = ? ORDER BY borrowers.surname, borrowers.firstname");
845
        my $q = "$select AND items.location = ? ORDER BY borrowers.surname, borrowers.firstname";
873
        $sth->execute($branch, $location);
846
        return @{ $dbh->selectall_arrayref($q, { Slice => {} }, $branch, $location ) };
874
    } else {
847
    } else {
875
        $sth = $dbh->prepare("$select ORDER BY borrowers.surname, borrowers.firstname");
848
        my $q = "$select ORDER BY borrowers.surname, borrowers.firstname";
876
        $sth->execute($branch);
849
        return @{ $dbh->selectall_arrayref($q, { Slice => {} }, $branch ) };
877
    }
850
    }
878
    while ( my $data = $sth->fetchrow_hashref ) {
879
    #check if the document has already been notified
880
        my $countnotify = CheckItemNotify($data->{'notify_id'}, $data->{'notify_level'}, $data->{'itemnumber'});
881
        if ($countnotify eq '0') {
882
            $getoverdues[$i] = $data;
883
            $i++;
884
        }
885
    }
886
    return (@getoverdues);
887
}
888
889
890
=head2 AddNotifyLine
891
892
    &AddNotifyLine($borrowernumber, $itemnumber, $overduelevel, $method, $notifyId)
893
894
Create a line into notify, if the method is phone, the notification_send_date is implemented to
895
896
=cut
897
898
sub AddNotifyLine {
899
    my ( $borrowernumber, $itemnumber, $overduelevel, $method, $notifyId ) = @_;
900
    my $dbh = C4::Context->dbh;
901
    if ( $method eq "phone" ) {
902
        my $sth = $dbh->prepare(
903
            "INSERT INTO notifys (borrowernumber,itemnumber,notify_date,notify_send_date,notify_level,method,notify_id)
904
        VALUES (?,?,now(),now(),?,?,?)"
905
        );
906
        $sth->execute( $borrowernumber, $itemnumber, $overduelevel, $method,
907
            $notifyId );
908
    }
909
    else {
910
        my $sth = $dbh->prepare(
911
            "INSERT INTO notifys (borrowernumber,itemnumber,notify_date,notify_level,method,notify_id)
912
        VALUES (?,?,now(),?,?,?)"
913
        );
914
        $sth->execute( $borrowernumber, $itemnumber, $overduelevel, $method,
915
            $notifyId );
916
    }
917
    return 1;
918
}
919
920
=head2 RemoveNotifyLine
921
922
    &RemoveNotifyLine( $borrowernumber, $itemnumber, $notify_date );
923
924
Cancel a notification
925
926
=cut
927
928
sub RemoveNotifyLine {
929
    my ( $borrowernumber, $itemnumber, $notify_date ) = @_;
930
    my $dbh = C4::Context->dbh;
931
    my $sth = $dbh->prepare(
932
        "DELETE FROM notifys 
933
            WHERE
934
            borrowernumber=?
935
            AND itemnumber=?
936
            AND notify_date=?"
937
    );
938
    $sth->execute( $borrowernumber, $itemnumber, $notify_date );
939
    return 1;
940
}
851
}
941
852
942
=head2 GetOverdueMessageTransportTypes
853
=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 1279-1299 CREATE TABLE `need_merge_authorities` ( -- keeping track of authority records st Link Here
1279
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1279
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1280
1280
1281
--
1281
--
1282
-- Table structure for table `notifys`
1283
--
1284
1285
DROP TABLE IF EXISTS `notifys`;
1286
CREATE TABLE `notifys` (
1287
  `notify_id` int(11) NOT NULL default 0,
1288
  `borrowernumber` int(11) NOT NULL default 0,
1289
  `itemnumber` int(11) NOT NULL default 0,
1290
  `notify_date` date default NULL,
1291
  `notify_send_date` date default NULL,
1292
  `notify_level` int(1) NOT NULL default 0,
1293
  `method` varchar(20) NOT NULL default ''
1294
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1295
1296
--
1297
-- Table structure for table `oai_sets`
1282
-- Table structure for table `oai_sets`
1298
--
1283
--
1299
1284
1300
- 

Return to bug 10021