Browse Source

WOrk in progress

master
chris 25 years ago
parent
commit
ee3287e87c
  1. 13
      C4/Accounts.pm
  2. 34
      C4/Circulation.pm
  3. 165
      C4/Interface.pm
  4. 5
      C4/Search.pm

13
C4/Accounts.pm

@ -53,6 +53,19 @@ my $priv_func = sub {
sub checkaccount {
#take borrower number
#check accounts and list amounts owing
my ($bornumber,$dbh)=@_;
my $sth=$dbh->prepare("Select * from accountlines where
borrowernumber=$bornumber");
$sth->execute;
my $total=0;
while (my @data=$sth->fetchrow_array){
$total=$total+$data[8];
}
$sth->finish;
if ($total > 0){
print "borrower owes $total\n";
}
return($total);
}
sub reconcileaccount {

34
C4/Circulation.pm

@ -52,11 +52,14 @@ my $priv_func = sub {
# make all your functions, whether exported or not;
sub Issue {
my ($bornum)=@_;
#get borrowerbarcode from scanner
my $borcode=&scanborrower;
# print $bornum;
my $dbh=&C4Connect;
my $sth=$dbh->prepare("Select * from borrowers where borrowernumber=$bornum");
my $sth=$dbh->prepare("Select * from borrowers where barcode=$borcode");
$sth->execute;
my @borrower=$sth->fetchrow_array;
my $bornum=$borrower[0];
$sth->finish;
#process borrower traps (could be function)
#check first GNA trap (no address this is the 22nd item in the table)
@ -79,12 +82,12 @@ sub Issue {
#call overdue checker
&checkoverdues($bornum);
#check amountowing
my $amount=checkaccount($bornum); #from C4::Accounts
my $amount=checkaccount($bornum,$dbh); #from C4::Accounts
#check if borrower has any items waiting
&checkwaiting;
#deal with any money still owing
if ($amount > 0){
&reconcileamount($bornum);
&reconcileaccount($bornum,$dbh);
}
#deal with alternative loans
#now check items
@ -95,7 +98,7 @@ sub Issue {
sub processitems {
my ($bornum)=@_;
my $itemnum=&scan;
my $itemnum=&scanbook;
my $dbh=&C4Connect;
my $sth=$dbh->prepare("Select * from items where barcode = '$itemnum'");
$sth->execute;
@ -136,12 +139,16 @@ sub checkoverdues{
sub previousissue {
my ($itemnum,$dbh)=@_;
my $sth=$dbh->prepare("Select borrowernumber from issues where itemnumber='$itemnum'");
my $sth=$dbh->prepare("Select firstname,surname,issues.borrowernumber
from issues,borrowers where
issues.itemnumber='$itemnum' and
issues.borrowernumber=borrowers.borrowernumber");
$sth->execute;
my @borrower=$sth->fetchrow_array;
$sth->finish;
if ($borrower[0] ne ''){
print "book is issued to borrower $borrower[0]\n";
print "book is issued to borrower $borrower[0] $borrower[1] borrowernumber
$borrower[2]\n";
return("out");
}
}
@ -152,10 +159,17 @@ sub checkwaiting{
}
sub scan {
sub scanbook {
#scan barcode
# my $number='L01781778';
my $number=&userdialog('console','Please enter a book barcode');
return ($number);
}
sub scanborrower {
#scan barcode
my $number='L01470967';
# my $number=&userdialog('console','Please enter a book barcode');
# my $number='L01781778';
my $number=&userdialog('console','Please enter a borrower barcode');
return ($number);
}

165
C4/Interface.pm

@ -3,7 +3,9 @@ package C4::Interface; #asummes C4/Interface
#uses newt
use strict;
use Newt qw(:anchors :macros);
use Curses;
use Curses::Widgets;
require Exporter;
use DBI;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ -52,25 +54,154 @@ sub userdialog{
#create a dialog
my ($type,$text)=@_;
if ($type eq 'console'){
&newtdialog($text);
my ($mwh, $dwh);
my ($colours);
$mwh = new Curses;
$colours = has_colors();
noecho();
cbreak();
halfdelay(10);
$mwh->keypad(1);
init_colours();
main_win($mwh);
$dwh = $mwh->subwin(8, $COLS - 2, 1, 1);
dialog($text,'red',$dwh,$mwh);
grab_key($mwh);
my @input=&input($mwh,$text);
}
}
sub newtdialog {
my ($text)=@_;
Newt::Init();
Newt::Cls();
Newt::DrawRootText(0, 0, "Get Item barcode");
my $label = Newt::Label($text);
my $width=10;
my $flags="oi";
my $entry = Newt::Entry($width, $flags);
my $main = Newt::Panel(1,2, 'Barcode')
->Add(0, 0, $entry, NEWT_ANCHOR_LEFT, 0, 0, 0, 1)
->Run();
my $data= $entry->Get();
Newt::Finished;
return($data);
sub main_win {
my ($mwh)=@_;
$mwh->erase();
# This function selects a few common colours for the foreground colour
select_colour(\$mwh, 'red');
$mwh->box(ACS_VLINE, ACS_HLINE);
$mwh->attrset(0);
$mwh->standout();
$mwh->addstr(0, 1, "Welcome to the Kumara Issues Screen");
$mwh->standend();
}
sub dialog {
my ($text, $colour,$dwh,$mwh) = @_;
my (@lines) = split(/\n/, $text);
my ($i, $j, $line);
for ($i = 1; $i < 7; $i++) {
if (defined ($lines[$i -1])) {
$line = $lines[$i -1] . "\n";
} else {
$line ="\n";
}
$dwh->addstr($i, 2, $line);
}
select_colour(\$dwh,$colour);
$dwh->box(ACS_VLINE, ACS_HLINE);
$dwh->attrset(0);
touchwin($mwh);
$mwh->refresh();
}
sub input{
my ($mwh,$text)=@_;
my ($text, $content) = txt_field( 'window' => \$mwh,
'title' =>$text,
'xpos' => 1,
'ypos' => 9,
'lines' => 5,
'cols' => $COLS - 4,
'content' => ' ',
'border' =>'green');
return($content);
}
sub grab_key {
my ($mwh)=@_;
my ($key) = -1;
while ($key eq -1) {
$key= $mwh->getch();
}
return $key;
}
END { } # module clean-up code here (global destructor)

5
C4/Search.pm

@ -55,12 +55,13 @@ my $priv_func = sub {
sub CatSearch {
my ($searchstring,$type)=@_;
my $dbh = &C4Connect;
my $query="Select * from biblio where $type like '%$searchstring%'";
my $query="Select * from catalogueentry where catalogueentry like
'%$searchstring%' and entrytype like '$type%'";
print $query,"\n";
my $sth=$dbh->prepare($query);
$sth->execute;
while (my @data=$sth->fetchrow_array){
print @data,"\n";
print "$data[0]\n";
}
$sth->execute;
$sth->finish;

Loading…
Cancel
Save