Skip to content

Commit

Permalink
Moduł inwentarza, zmiany w plikach wspólnych.
Browse files Browse the repository at this point in the history
  • Loading branch information
rafko committed Mar 10, 2015
1 parent fd6176d commit 1fec8e5
Show file tree
Hide file tree
Showing 14 changed files with 168 additions and 3 deletions.
9 changes: 8 additions & 1 deletion C4/Items.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2164,7 +2164,8 @@ sub _koha_new_item {
enumchron = ?,
more_subfields_xml = ?,
copynumber = ?,
stocknumber = ?
stocknumber = ?,
accq_type = ?
";
my $sth = $dbh->prepare($query);
my $today = C4::Dates->today('iso');
Expand Down Expand Up @@ -2207,6 +2208,7 @@ sub _koha_new_item {
$item->{'more_subfields_xml'},
$item->{'copynumber'},
$item->{'stocknumber'},
$item->{'accq_type'},
);

my $itemnumber;
Expand Down Expand Up @@ -2249,6 +2251,11 @@ sub MoveItemFromBiblio {
$order->{'biblionumber'} = $tobiblio;
C4::Acquisition::ModOrder($order);
}
require C4::Inventory;

my ( $result, $error ) = C4::Inventory::RefreshItemInInventory( { itemnumber=> $itemnumber } );
warn "error: $error" unless defined $result;

return $tobiblio;
}
return;
Expand Down
4 changes: 4 additions & 0 deletions acqui/invoice.pl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ =head1 DESCRIPTION

use Koha::Acquisition::Bookseller;
use Koha::Misc::Files;
use C4::Inventory qw/SearchInvBookAccessions/;

my $input = new CGI;
my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
Expand Down Expand Up @@ -154,7 +155,10 @@ =head1 DESCRIPTION
push @budgets_loop, \%line;
}

my $accession = SearchInvBookAccessions({ invoice_id => $details->{'invoiceid'}});

$template->param(
accession => $accession,
invoiceid => $details->{'invoiceid'},
invoicenumber => $details->{'invoicenumber'},
suppliername => $details->{'suppliername'},
Expand Down
16 changes: 16 additions & 0 deletions acqui/parcels.pl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ =head1 CGI PARAMETERS
use C4::Dates qw/format_date/;
use C4::Acquisition;
use C4::Budgets;
use C4::Inventory qw/ GetInvBookAccession ModInvBookAccession /;

use Koha::Acquisition::Bookseller;

Expand All @@ -98,6 +99,15 @@ =head1 CGI PARAMETERS
debug => 1,
}
);
my $accession_id = $input->param('accession_id');
if ( defined $accession_id && $accession_id) {
my $detail = GetInvBookAccession($accession_id);
$booksellerid = $detail->{vendor_id};
$template->param(
accession_name => $detail->{accession_number},
accession_id => $accession_id,
);
}

my $invoicenumber = $input->param('invoice');
my $shipmentdate = $input->param('shipmentdate');
Expand Down Expand Up @@ -134,6 +144,12 @@ =head1 CGI PARAMETERS
);
if(defined $invoiceid) {
# Successful 'Add'
if (defined $accession_id && $accession_id) {
ModInvBookAccession({
accession_id => $accession_id,
invoice_id => $invoiceid,
});
}
print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid");
exit 0;
} else {
Expand Down
21 changes: 21 additions & 0 deletions catalogue/moredetail.pl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use C4::Reserves qw(GetReservesFromBiblionumber);

use Koha::Acquisition::Bookseller;
use C4::Inventory qw(GetInvBookItemInfoByItemNr AddItemToInventory_BPK_Book);
use Koha::DateUtils;

my $query=new CGI;
Expand Down Expand Up @@ -199,6 +200,26 @@
}
}

{
last unless C4::Context->preference("InventoryBookEnable");

my $ibitem = GetInvBookItemInfoByItemNr( $item->{'itemnumber'} );
$item->{invbookitem} = $ibitem;
$ibitem->{invbook_item_id} && last;

last unless (C4::Context->preference("InventoryBookVariant")
&& C4::Context->preference("InventoryBookVariant") eq 'BPK');

my ($result, $ecode) = AddItemToInventory_BPK_Book( {
itemnumber => $item->{'itemnumber'},
check_possibility => 1,
} );
my $invbcp = { not_ok => $ecode };
ref($ecode) eq 'HASH' && do {
$invbcp = { add_ok => $ecode };
};
$item->{invbookcheckp} = $invbcp;
}
}
$template->param(count => $data->{'count'},
subscriptionsnumber => $subscriptionsnumber,
Expand Down
17 changes: 17 additions & 0 deletions catalogue/updateitem.pl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use C4::Output;
use C4::Circulation;
use C4::Reserves;
use C4::Inventory qw(GetInvBookItemInfoByItemNr AddItemToInventory_BPK_Book);

my $cgi= new CGI;

Expand All @@ -40,6 +41,22 @@
my $withdrawn=$cgi->param('withdrawn');
my $damaged=$cgi->param('damaged');

{
## FIXME: would be probably better to have separate script for that action
last unless (C4::Context->preference("InventoryBookEnable")
&& C4::Context->preference("InventoryBookVariant")
&& C4::Context->preference("InventoryBookVariant") eq 'BPK');

my $invbook_action_add = $cgi->param('invbook_action_add');
($invbook_action_add && $itemnumber) || last;

my ($result, $ecode) = AddItemToInventory_BPK_Book( { itemnumber => $itemnumber } );
## FIXME: proper error handling etc.

print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber");
exit;
}

my $confirm=$cgi->param('confirm');
my $dbh = C4::Context->dbh;

Expand Down
55 changes: 54 additions & 1 deletion cataloguing/additem.pl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use Storable qw(thaw freeze);
use URI::Escape;
use C4::Members;
use C4::Inventory;

use MARC::File::XML;
use URI::Escape;
Expand Down Expand Up @@ -465,6 +466,28 @@ sub removeFieldsForPrefill {
$cookie = [ $cookie, $itemcookie ];
}

#Add item to inventory
if ( $input->param('addto_inv') ) {

my $accession_id;
if ( $input->param('mod_acc') ) {
my $accession_number = $record->subfield('952',"f");
my $accession = SearchInvBookAccessions({ accession_number => $accession_number }) if defined $accession_number;
$accession_id = $accession->[0]->{accession_id};
}
my ( $success, $ivb_error ) = AddItemToInventory({
itemnumber => $oldbibitemnum,
invbook_id => $input->param('inv_book'),
accession_id => $accession_id,
});
push @errors, $ivb_error if !$success;
DelItem({
itemnumber => $oldbibitemnum,
biblionumber => $oldbiblionumber,
}) if !$success;
#TODO: if not success delete new item?
}

}
$nextop = "additem";
if ($exist_itemnumber) {
Expand Down Expand Up @@ -632,10 +655,40 @@ sub removeFieldsForPrefill {
# check that the barcode don't exist already
my $addedolditem = TransformMarcToKoha($dbh,$itemtosave);
my $exist_itemnumber = get_item_from_barcode($addedolditem->{'barcode'});
my $olditem_data = GetItem($itemnumber);
if ($exist_itemnumber && $exist_itemnumber != $itemnumber) {
push @errors,"barcode_not_unique";
} else {
ModItemFromMarc($itemtosave,$biblionumber,$itemnumber);

my $accession_id;
if ( $input->param('mod_acc') ) {
my $accession_number = $itemtosave->subfield('952',"f");
my $accession = SearchInvBookAccessions({ accession_number => $accession_number }) if defined $accession_number;
$accession_id = $accession->[0]->{accession_id};
}

#Add item to inventory
if ( $input->param('addto_inv') ) {
my $inventory_item = ({
itemnumber => $itemnumber,
invbook_id => $input->param('inv_book'),
});
$inventory_item->{accession_id} = $accession_id if defined $accession_id;
my ( $success, $ivb_error ) =
AddItemToInventory($inventory_item);
if ( !$success ){
push @errors, $ivb_error;
ModItem({ stocknumber => $olditem_data->{stocknumber} }, $biblionumber, $itemnumber);
}
} elsif ( $input->param('mod_acc') && defined $accession_id ){
my $result = SearchInvBookItems( { itemnumber => $itemnumber } );
($result && ref($result) eq 'ARRAY' && @$result == 1) || push @errors, 'ITEM_NOT_FOUND';
ModInvBookItem({
invbook_item_id => $result->[0]->{invbook_item_id},
accession_id => $accession_id,
});
}
$itemnumber="";
}
my $item = GetItem( $itemnumber );
Expand Down Expand Up @@ -673,7 +726,6 @@ sub removeFieldsForPrefill {
my $temp = GetMarcBiblio( $biblionumber );
#my @fields = $record->fields();


my %witness; #---- stores the list of subfields used at least once, with the "meaning" of the code
my @big_array;
#---- finds where items.itemnumber is stored
Expand All @@ -682,6 +734,7 @@ sub removeFieldsForPrefill {
C4::Biblio::EmbedItemsInMarcBiblio($temp, $biblionumber);
my @fields = $temp->fields();

$temp->{accession_id} = $input->param('accession_id') if defined $input->param('accession_id');

my @hostitemnumbers;
if ( C4::Context->preference('EasyAnalyticalRecords') ) {
Expand Down
13 changes: 13 additions & 0 deletions koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
Original file line number Diff line number Diff line change
Expand Up @@ -2764,3 +2764,16 @@ span.onsite_checkout {
border-radius: 4px;
border : 1px solid #FFF2CE;
}

.sorted tbody td.editable {
background-color: #FFFFCC;
}
.selected { background-color : #CCE0FC; }

td.details_control {
background: url('../../img/details_open.png') no-repeat center center;
cursor: pointer;
}
tr.shown td.details_control {
background: url('../../img/details_close.png') no-repeat center center;
}
6 changes: 6 additions & 0 deletions koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@

</ul>

<h5>Inventory books</h5>
<ul>
<li><a href="/cgi-bin/koha/inventory/inventory_books_definitions.pl">Book definitions</a></li>
<li><a href="/cgi-bin/koha/inventory/inventory_books_permissions.pl">Set up book permissions</a>
</ul>

<h5>Additional parameters</h5>

<ul>
Expand Down
1 change: 1 addition & 0 deletions koha-tmpl/intranet-tmpl/prog/en/includes/header.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[% IF ( intranetbookbag ) %]
<li><a href="#" id="cartmenulink">Cart<span id="basketcount"></span></a></li>
[% END %]
<li><a href="/cgi-bin/koha/inventory/inventory-home.pl" id="inventorymenulink">Inwentarz</a></li>
[% IntranetNav %]
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">More <b class="caret"></b></a>
Expand Down
2 changes: 2 additions & 0 deletions koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@
<p>
<a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]">Go to receipt page</a>
[% IF Koha.Preference('AcqEnableFiles') %]| <a href="/cgi-bin/koha/acqui/invoice-files.pl?invoiceid=[% invoiceid %]">Manage invoice files</a>[% END %]
[%- IF ( accession ) -%] | Powiązane akcesje:
[% FOREACH accessloo IN accession %] <a href="/cgi-bin/koha/inventory/accession_manage.pl?acc_id=[% accessloo.accession_id %]">[% accessloo.accession_number %]</a> |[% END %] [%- END -%]
</p>
<h2>Invoice details</h2>
[% IF orders_loop.size %]
Expand Down
4 changes: 3 additions & 1 deletion koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<input type="hidden" name="shipmentdate" value="[% shipmentdate | $KohaDates %]" />
<input type="hidden" name="shipmentcost" value="[% shipmentcost %]" />
<input type="hidden" name="shipmentcost_budgetid" value="[% shipmentcost_budgetid %]" />
<input type="hidden" name="accession_id" value="[% accession_id %]" />
<input type="submit" class="button" value="Create new invoice anyway" />
</form>
</div>
Expand Down Expand Up @@ -157,7 +158,8 @@
<label for="invoice">Vendor invoice </label>
<input type="hidden" name="booksellerid" value="[% booksellerid %]" />
<input type="hidden" name="op" value="new" />
<input type="text" size="20" id="invoice" name="invoice" class="focus" />
<input type="hidden" name="accession_id" value="[% accession_id %]" />
<input type="text" size="20" id="invoice" name="invoice" class="focus" value="[% accession_name %]"/>
</li>
[% IF ( gst ) %]
<li>
Expand Down
12 changes: 12 additions & 0 deletions koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[% USE Koha %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Administration</title>
[% INCLUDE 'doc-head-close.inc' %]
Expand Down Expand Up @@ -57,6 +58,17 @@
<dt><a href="/cgi-bin/koha/admin/cities.pl">Cities and towns</a></dt>
<dd>Define cities and towns that your patrons live in.</dd>
</dl>

[% IF (Koha.Preference('InventoryBookEnable')) %]
<h3>Inventory books</h3>
<dl>
<dt><a href="/cgi-bin/koha/inventory/inventory_books_definitions.pl">Manage inventory books definitions</a></dt>
<dd>Define, manage, set up and configure various kinds of inventory book types (inventory books, accession books, writeoff books).</dd>
<dt><a href="/cgi-bin/koha/inventory/inventory_books_permissions.pl">Set up inventory books permissions</a></dt>
<dd>Configure permissions for individual inventory books and particular staff users.</dd>
</dl>
[% END %]

</div>
<div class="yui-u">
<h3>Catalog</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
</head>
<body id="catalog_moredetail" class="catalog">
[% USE KohaDates %]
[% USE Koha %]
[% INCLUDE 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]

Expand Down Expand Up @@ -234,6 +235,9 @@
</li>
</ol>
</div>

[% IF ( Koha.Preference('InventoryBookEnable') ) %][% INCLUDE 'cat-moredetail-invbook-item.inc' %][% END %]

</div>
[% END %]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ $(document).ready(function() {
<h1>Items for [% title |html %] [% IF ( author ) %] by [% author %][% END %] (Record #[% biblionumber %])</h1>

[% IF ( barcode_not_unique ) %]<div class="dialog alert"><strong>Error saving item</strong>: Barcode must be unique.</div>[% END %]
[% IF ( IVB_ENTRY_ADD_UNSUCCESSFULL ) %]<div class="dialog alert"><strong>Błąd dodawania do inwenarza</strong>: Prawdopodobnie, brak jenego z pól obowiązkowych.</div>[% END %]
[% IF ( IVB_ENTRY_ALREADY_EXISTS ) %]<div class="dialog alert"><strong>Błąd dodawania do inwentarza</strong>: Egzemplarz o tym numerze już istnieje. </div>[% END %]
[% IF ( ITEM_ALREADY_IN_INV ) %]<div class="dialog alert"><strong>Błąd dodawania do inwentarza</strong>: Już dodany do inwentarza pod innym numerem. </div>[% END %]
[% IF ( ITEM_NOT_FOUND ) %]<div class="dialog alert"><strong>Błąd dodawania do inwentarza</strong>: Nie znaleziono egzemplarza. </div>[% END %]
[% IF ( NO_INV_BOOK_ID ) %]<div class="dialog alert"><strong>Błąd dodawania do inwentarza</strong>: Brak ID księgi inwentarzowej. </div>[% END %]
[% IF ( NO_DATA ) %]<div class="dialog alert"><strong>Błąd dodawania do inwentarza</strong>: Brak danych danych. </div>[% END %]
[% IF ( NO_ITEM ) %]<div class="dialog alert"><strong>Błąd dodawania do inwentarza</strong>: Brak rzeczonego egzemplarza. </div>[% END %]
[% IF ( no_next_barcode ) %]<div class="dialog alert"><strong>Error saving items</strong>: Unable to automatically determine values for barcodes. No item has been inserted.</div>[% END %]
[% IF ( book_on_loan ) %]<div class="dialog alert"><strong>Cannot delete</strong>: item is checked out.</div>[% END %]
[% IF ( book_reserved ) %]<div class="dialogalert"><strong>Cannot delete</strong>: item has a waiting hold.</div>[% END %]
Expand Down

0 comments on commit 1fec8e5

Please sign in to comment.