# 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
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
=head1 NAME
=cut
use strict;
+use warnings;
use C4::Auth;
use C4::Acquisition;
+use C4::Contract;
use C4::Biblio;
use C4::Output;
+use C4::Dates qw/format_date /;
use CGI;
use C4::Bookseller;
debug => 1,
}
);
-my $GST = $booksellers[0]->{'gstrate'} || C4::Context->preference("gist");
+my $seller_gstrate = $booksellers[0]->{'gstrate'};
+# A perl-ism: '0'==false, '0.000'==true, but 0=='0.000' - this accounts for that
+undef $seller_gstrate if ($seller_gstrate == 0);
+my $GST = $seller_gstrate || C4::Context->preference("gist");
$GST *= 100;
+
+my @contracts = GetContracts($id);
+my $contractcount = scalar(@contracts);
+$template->param(hascontracts => 1) if ($contractcount > 0);
+
#build array for currencies
if ($op eq "display") {
+
+ # get contracts
+ my @contracts = @{GetContract( { booksellerid => $id } )};
+
+ # format dates
+ for ( @contracts ) {
+ $$_{contractstartdate} = format_date($$_{contractstartdate});
+ $$_{contractenddate} = format_date($$_{contractenddate});
+ }
+
$template->param(
id => $id,
name => $booksellers[0]->{'name'},
contnotes => $booksellers[0]->{'contnotes'},
notes => $booksellers[0]->{'notes'},
active => $booksellers[0]->{'active'},
- specialty => $booksellers[0]->{'specialty'},
gstreg => $booksellers[0]->{'gstreg'},
listincgst => $booksellers[0]->{'listincgst'},
invoiceincgst => $booksellers[0]->{'invoiceincgst'},
- gstrate => $booksellers[0]->{'gstrate'},
+ gstrate => $booksellers[0]->{'gstrate'}*100,
discount => $booksellers[0]->{'discount'},
invoiceprice => $booksellers[0]->{'invoiceprice'},
listprice => $booksellers[0]->{'listprice'},
GST => $GST,
basketcount => $booksellers[0]->{'basketcount'},
+ contracts => \@contracts
);
}
elsif ($op eq 'delete') {
push @loop_invoicecurrency, { currency => "<option value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"};
}
}
- my $GST = $booksellers[0]->{'gstrate'} || C4::Context->preference("gist");
- $GST *= 100;
$template->param(
id => $id,
name => $booksellers[0]->{'name'},
contemail => $booksellers[0]->{'contemail'},
contnotes => $booksellers[0]->{'contnotes'},
notes => $booksellers[0]->{'notes'},
- active => $booksellers[0]->{'active'},
- specialty => $booksellers[0]->{'specialty'},
+ active => $id?$booksellers[0]->{'active'}:1, # set active ON by default for supplier add (id empty for add)
gstreg => $booksellers[0]->{'gstreg'},
listincgst => $booksellers[0]->{'listincgst'},
invoiceincgst => $booksellers[0]->{'invoiceincgst'},
- gstrate => $booksellers[0]->{'gstrate'},
+ gstrate => $booksellers[0]->{'gstrate'}*100,
discount => $booksellers[0]->{'discount'},
loop_pricescurrency => \@loop_pricescurrency,
loop_invoicecurrency => \@loop_invoicecurrency,
enter => 1,
);
}
+
+
+
output_html_with_http_headers $query, $cookie, $template->output;