Browse Source

basket header management

3.2.x
Paul Poulain 15 years ago
committed by Henri-Damien LAURENT
parent
commit
5a6d8e7f7c
  1. 124
      acqui/basketheader.pl
  2. 168
      koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tmpl

124
acqui/basketheader.pl

@ -0,0 +1,124 @@
#!/usr/bin/perl
#script to add basket and edit header options (name, notes and contractnumber)
#written by john.soros@biblibre.com 15/09/2008
# Copyright 2008 - 2009 BibLibre SARL
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
=head1 NAME
basketheader.pl
=head1 DESCRIPTION
This script is used to edit the basket's "header", or add a new basket, the header contains the supplier ID,
notes to the supplier, local notes, and the contractnumber, which identifies the basket to a specific contract.
=head1 CGI PARAMETERS
=over 4
=item supplierid
C<$supplierid> is the id of the supplier we add the basket to.
=item basketid
If it exists, C<$basketno> is the basket we edit
=back
=cut
use strict;
use warnings;
use CGI;
use C4::Context;
use C4::Auth;
use C4::Output;
use C4::Acquisition qw/GetBasket NewBasket GetContracts ModBasketHeader/;
use C4::Bookseller qw/GetBookSellerFromId/;
my $input = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "acqui/basketheader.tmpl",
query => $input,
type => "intranet",
authnotrequired => 0,
flagsrequired => { acquisition => 'order_manage' },
debug => 1,
}
);
#parameters:
my $booksellerid;
$booksellerid = $input->param('booksellerid');
my $basketno = $input->param('basketno');
my $basket;
my $op = $input ->param('op');
my $is_an_edit= $input ->param('is_an_edit');
if ( $op eq 'add_form' ) {
my @contractloop;
if ( $basketno ) {
#this is an edit
$basket = GetBasket($basketno);
if (! $booksellerid) {
$booksellerid=$basket->{'booksellerid'};
}
@contractloop = &GetContracts($booksellerid, 1);
for (@contractloop) {
if ( $basket->{'contractnumber'} eq $_->{'contractnumber'} ) {
$_->{'selected'} = 1;
}
}
$template->param( is_an_edit => 1);
} else {
#new basket
my $basket;
push(@contractloop, &GetContracts($booksellerid, 1));
}
my $bookseller = GetBookSellerFromId($booksellerid);
my $count = scalar @contractloop;
if ( $count > 0) {
$template->param(contractloop => \@contractloop,
basketcontractnumber => $basket->{'contractnumber'});
}
$template->param( add_form => 1,
basketname => $basket->{'basketname'},
basketnote => $basket->{'note'},
basketbooksellernote => $basket->{'booksellernote'},
booksellername => $bookseller->{'name'},
booksellerid => $booksellerid,
basketno => $basketno
);
#End Edit
} elsif ( $op eq 'add_validate' ) {
#we are confirming the changes, save the basket
$template->param(add_validate => 1);
if ( $is_an_edit ) {
ModBasketHeader($input->param('basketno'),$input->param('basketname'),$input->param('basketnote'),$input->param('basketbooksellernote'),$input->param('basketcontractnumber'));
$template->param( basketno => $basketno );
} else { #New basket
my $basketno = NewBasket($booksellerid, $loggedinuser, $input->param('basketname'), $input->param('basketnote'), $input->param('basketbooksellernote'), $input->param('basketcontractnumber'));
$template->param( basketno => $basketno );
}
}
output_html_with_http_headers $input, $cookie, $template->output;

168
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tmpl

@ -0,0 +1,168 @@
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
<title>Koha &rsaquo;
<!-- TMPL_IF NAME="add_form" -->
<!-- TMPL_IF NAME="basketno" -->Edit basket '<!-- TMPL_VAR NAME="basketname" -->'
<!-- TMPL_ELSE -->add a basket to <!-- TMPL_VAR name="booksellername" -->
<!-- /TMPL_IF -->
<!-- /TMPL_IF -->
</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<script type="text/javascript" src="<!-- TMPL_VAR NAME='themelang' -->/js/acq.js"></script>
<script type="text/javascript">
//<![CDATA[
// to check if the data are correctly entered.
function Check(ff) {
var ok=0;
var _alertString="Form not submitted because of the following problem(s)\n";
_alertString +="-------------------------------------------------------------------\n\n";
if (!(isNotNull(ff.basketname,0))){
ok=1;
_alertString += "- name missing\n";
}
if (ok) { // if there is a problem
alert(_alertString);
return false;
}
// if all is good
ff.submit();
}
//]]>
</script>
<style type="text/css">
div.workarea { padding:10px; float:left }
ul.draglist {
position: relative;
width: 200px;
height:240px;
background: #f7f7f7;
border: 1px solid gray;
list-style: none;
margin:0;
padding:0;
}
ul.draglist li {
margin: 1px;
cursor: move;
zoom: 1;
}
ul.draglist_alt {
position: relative;
width: 200px;
list-style: none;
margin:0;
padding:0;
/*
The bottom padding provides the cushion that makes the empty
list targetable. Alternatively, we could leave the padding
off by default, adding it when we detect that the list is empty.
*/
padding-bottom:20px;
}
ul.draglist_alt li {
margin: 1px;
cursor: move;
}
li.list1 {
background-color: #D1E6EC;
border:1px solid #7EA6B2;
}
li.list2 {
background-color: #D8D4E2;
border:1px solid #6B4C86;
}
#user_actions { float: right; }
</style>
</head>
<body>
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="acquisitions-search.inc" -->
<div id="breadcrumbs">
<a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
<a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo;
<!-- TMPL_IF NAME="add_form" -->
<!-- TMPL_IF NAME="basketno" -->Edit basket '<!-- TMPL_VAR NAME="basketname" -->'
<!-- TMPL_ELSE -->add a basket to <!-- TMPL_VAR name="booksellername" -->
<!-- /TMPL_IF -->
<!-- /TMPL_IF -->
</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<!-- TMPL_IF NAME="add_form" -->
<!-- TMPL_IF name="basketno" -->
<h1>Edit basket <!-- TMPL_VAR NAME="basketname" --></h1>
<!-- TMPL_ELSE --><h1>Add a basket to <!-- TMPL_VAR name="booksellername" --></h1>
<!-- /TMPL_IF -->
<form name="Aform" action="<!-- TMPL_VAR NAME="script_name" -->" method="post">
<input type="hidden" name="booksellerid" value="<!-- TMPL_VAR NAME="booksellerid" -->" />
<fieldset class="rows">
<ol>
<!-- TMPL_IF NAME="basketno" -->
<li>
<input type="hidden" name="basketno" value="<!-- TMPL_VAR NAME="basketno" -->" />
<input type="hidden" name="is_an_edit" value="1" />
</li>
<!-- /TMPL_IF -->
<li>
<label for="basketname">Basket name</label> &nbsp;
<input type="text" name="basketname" id="basketname" size="40" maxlength="80" value="<!-- TMPL_VAR NAME="basketname" -->" />
</li>
<li>
<label for="basketnote">Internal note</label> &nbsp;
<textarea name="basketnote" id="basketnote" rows="5" cols="40"><!-- TMPL_VAR NAME="basketnote" --></textarea>
</li>
<li>
<label for="basketbooksellernote">Bookseller note</label> &nbsp;
<textarea name="basketbooksellernote" id="basketbooksellernote" rows="5" cols="40"><!-- TMPL_VAR NAME="basketbooksellernote" --></textarea>
</li>
<!-- TMPL_IF NAME="contractloop" -->
<li><label for="basketcontractnumber">Contract</label>
<select id="basketcontractnumber" name="basketcontractnumber">
<option value="">No contract</option>
<!-- TMPL_LOOP NAME="contractloop" -->
<!-- TMPL_IF NAME="selected" -->
<option value="<!-- TMPL_VAR NAME="contractnumber" -->" selected="selected"><!-- TMPL_VAR NAME="contractname" --></option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR NAME="contractnumber" -->"><!-- TMPL_VAR NAME="contractname" --></option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select>
</li>
<!-- /TMPL_IF -->
</ol>
</fieldset>
<fieldset class="action">
<input type="hidden" name="op" value="add_validate" />
<input type="button" value="Save" onclick="Check(this.form);" />
</fieldset>
</form>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="add_validate" -->
<h3>Data recorded</h3>
<META HTTP-EQUIV=Refresh CONTENT="0; URL=basket.pl?basketno=<!-- TMPL_VAR NAME="basketno" -->">
<!-- /TMPL_IF -->
</div>
</div>
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="acquisitions-menu.inc" -->
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
Loading…
Cancel
Save