MT2345 : Changes on contracts
authorMatthias Meusburger <matthias.meusburger@biblibre.com>
Mon, 28 Dec 2009 10:21:49 +0000 (11:21 +0100)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Thu, 28 Jan 2010 14:11:51 +0000 (15:11 +0100)
acqui/supplier.pl
admin/aqcontract.pl
koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-toolbar.inc
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tmpl
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tmpl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tmpl

index b8afe0d..42b23b0 100755 (executable)
@@ -43,8 +43,10 @@ To know the bookseller this script has to display details.
 use strict;
 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;
@@ -66,8 +68,23 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user(
 );
 my $GST = $booksellers[0]->{'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'},
@@ -97,6 +114,7 @@ if ($op eq "display") {
                listprice     => $booksellers[0]->{'listprice'},
                GST           => $GST,
                basketcount   => $booksellers[0]->{'basketcount'},
+               contracts     => \@contracts
        );
 }
 elsif ($op eq 'delete') {
index 9476f06..f1cc17b 100755 (executable)
@@ -98,7 +98,7 @@ elsif ( $op eq 'add_validate' ) {
         });
     }
 
-    print $input->redirect("aqcontract.pl?booksellerid=$booksellerid");
+    print $input->redirect("/cgi-bin/koha/acqui/supplier.pl?supplierid=$booksellerid");
     exit;
 
     # END $OP eq ADD_VALIDATE
@@ -125,7 +125,7 @@ elsif ( $op eq 'delete_confirmed' ) {
 
     DelContract( { contractnumber => $contractnumber } );
 
-    print $input->redirect("aqcontract.pl?booksellerid=$booksellerid");
+    print $input->redirect("/cgi-bin/koha/acqui/supplier.pl?supplierid=$booksellerid");
     exit;
 
     # END $OP eq DELETE_CONFIRMED
index 99c8c4b..c3376fe 100644 (file)
@@ -44,7 +44,6 @@
         <!-- TMPL_IF NAME="id" -->
             <li><a id="editsupplier" href="/cgi-bin/koha/acqui/supplier.pl?supplierid=<!--TMPL_VAR Name="id"-->&amp;op=enter">Edit</a></li>
             <li><a id="newcontract" href="/cgi-bin/koha/admin/aqcontract.pl?op=add_form&booksellerid=<!-- TMPL_VAR name="id" -->">New Contract</a></li>
-            <li><a id="editcontracts" href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=<!-- TMPL_VAR name="id" -->">Contracts</a></li>
             <!-- TMPL_UNLESS NAME="basketcount" -->
                 <li><a id="newbasket" href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=<!-- TMPL_VAR name="id" -->">New Basket</a></li>
             <!-- /TMPL_UNLESS -->
index 561ce9a..c04ad12 100644 (file)
                 <!-- TMPL_IF NAME="basketbooksellernote" --><p>Vendor note: <!-- TMPL_VAR NAME="basketbooksellernote" --></p><!-- /TMPL_IF -->
                 <!-- TMPL_IF NAME="basketcontractno" -->
                     <p>Contract number: <!-- TMPL_VAR NAME="basketcontractno" --></p>
-                    <p>Contract name: <a href="../admin/aqcontract.pl?op=add_form&amp;contractnumber=<!-- TMPL_VAR NAME="basketcontractno" -->"><!-- TMPL_VAR NAME="basketcontractname" --></a></p>
+                    <p>Contract name: <a href="../admin/aqcontract.pl?op=add_form&amp;contractnumber=<!-- TMPL_VAR NAME="basketcontractno" -->&amp;booksellerid=<!-- TMPL_VAR NAME="booksellerid" -->"><!-- TMPL_VAR NAME="basketcontractname" --></a></p>
                 <!-- /TMPL_IF -->
                 <!-- TMPL_IF NAME="authorisedbyname" --><p>Managed by:  <!-- TMPL_VAR NAME="authorisedbyname" --></p><!-- /TMPL_IF -->
                 <!-- TMPL_IF NAME="creationdate" --><p>Open on:  <!-- TMPL_VAR NAME="creationdate" --></p><!-- /TMPL_IF -->
index 8b6b026..61e1d25 100644 (file)
@@ -202,6 +202,32 @@ if (f.company.value == "") {
             <!-- TMPL_IF NAME="notes" --><p><strong>Notes: </strong>
                 <!-- TMPL_VAR NAME="notes" --></p><!-- /TMPL_IF -->
         </div>
+
+                <!-- TMPL_IF name="contracts" -->
+                   <h3>Contract(s)</h3>
+                    <table>
+                        <tr>
+                            <th scope="col">Name</th>
+                            <th scope="col">Description</th>
+                            <th scope="col">Start date</th>
+                            <th scope="col">End date</th>
+                            <th scope="col" colspan="2">&nbsp; </th>
+                        </tr>
+                    <!-- TMPL_LOOP NAME="contracts" -->
+                        <!-- TMPL_IF NAME="__even__" --><tr class="highlight"><!-- TMPL_ELSE --><tr><!-- /TMPL_IF -->
+                        <td>
+                            <a href="/cgi-bin/koha/admin/aqcontract.pl?op=add_form&amp;contractnumber=<!-- TMPL_VAR NAME="contractnumber" -->&amp;booksellerid=<!-- TMPL_VAR name="booksellerid" -->"><!-- TMPL_VAR NAME="contractname" --></a>
+                        </td>
+                        <td><!-- TMPL_VAR NAME="contractdescription" --></td>
+                        <td><!-- TMPL_VAR NAME="contractstartdate" --></td>
+                        <td><!-- TMPL_VAR NAME="contractenddate" --></td>
+                        <td><a href="/cgi-bin/koha/admin/aqcontract.pl?op=add_form&amp;contractnumber=<!-- TMPL_VAR NAME="contractnumber" -->&amp;booksellerid=<!-- TMPL_VAR name="booksellerid" -->">Edit</a></td>
+                        <td><a href="/cgi-bin/koha/admin/aqcontract.pl?op=delete_confirm&amp;contractnumber=<!-- TMPL_VAR NAME="contractnumber" -->&amp;booksellerid=<!-- TMPL_VAR name="booksellerid" -->">Delete</a></td>
+                        </tr>
+                    <!-- /TMPL_LOOP -->
+                </table>
+                <!-- /TMPL_IF -->
+
 <!--/TMPL_IF-->
 
 </div>
index ae85de2..c9324c7 100644 (file)
@@ -108,17 +108,6 @@ function Check(ff) {
                                 <li><label for="contractdescription">Description</label> &nbsp;
                                         <input type="text" name="contractdescription" id="contractdescription" size="40" maxlength="80" value="<!-- TMPL_VAR NAME="contractdescription" -->" />
                                 </li>
-                                <li><label for="booksellerid">Vendor</label>
-                                <select id="booksellerid" name="booksellerid">
-                                <!-- TMPL_LOOP NAME="booksellerloop" -->
-                                    <!-- TMPL_IF NAME="selected" -->
-                                        <option value="<!-- TMPL_VAR NAME="id" -->" selected="selected"><!-- TMPL_VAR NAME="name" --></option>
-                                    <!-- TMPL_ELSE -->
-                                        <option value="<!-- TMPL_VAR NAME="id" -->"><!-- TMPL_VAR NAME="name" --></option>
-                                    <!-- /TMPL_IF -->
-                                <!-- /TMPL_LOOP -->
-                                </select>
-                                </li>
                                 <li><label for="contractstartdate" class="required">Start date *</label> &nbsp;
                                         <input type="text" name="contractstartdate" id="contractstartdate" value="<!-- TMPL_VAR NAME="contractstartdate" -->" maxlength="10"  size="10"/>
                                         <img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" id="contractstartdate_button" alt="Show Calendar" />