[MT2593] Added "ordered" column in acqui-home budget display
authorJean-André Santoni <jeanandre.santoni@biblibre.com>
Mon, 4 Jan 2010 14:35:43 +0000 (15:35 +0100)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Thu, 28 Jan 2010 14:11:52 +0000 (15:11 +0100)
C4/Budgets.pm
acqui/acqui-home.pl
koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-toolbar.inc
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tmpl

index 8ef85ed..4a8b3b6 100644 (file)
@@ -39,6 +39,7 @@ BEGIN {
         &ModBudget
         &DelBudget
         &GetBudgetSpent
+        &GetBudgetOrdered
         &GetPeriodsCount
 
            &GetBudgetPeriod
@@ -300,9 +301,26 @@ sub GetBudgetSpent {
        my ($budget_id) = @_;
        my $dbh = C4::Context->dbh;
        my $sth = $dbh->prepare(qq|
-        SELECT SUM(ecost *  quantity  ) AS sum FROM aqorders
+        SELECT SUM(ecost *  quantity) AS sum FROM aqorders
             WHERE budget_id = ? AND
-            datecancellationprinted IS NULL 
+            quantityreceived > 0 AND
+            datecancellationprinted IS NULL
+    |);
+
+       $sth->execute($budget_id);
+       my $sum =  $sth->fetchrow_array;
+       return $sum;
+}
+
+# -------------------------------------------------------------------
+sub GetBudgetOrdered {
+       my ($budget_id) = @_;
+       my $dbh = C4::Context->dbh;
+       my $sth = $dbh->prepare(qq|
+        SELECT SUM(ecost *  quantity) AS sum FROM aqorders
+            WHERE budget_id = ? AND
+            quantityreceived = 0 AND
+            datecancellationprinted IS NULL
     |);
 
        $sth->execute($budget_id);
index 8c6fcc8..ef457b7 100755 (executable)
@@ -78,6 +78,7 @@ my $branchname = GetBranchName($homebranch);
 my $classlist   = '';
 my $total       = 0;
 my $totspent    = 0;
+my $totordered  = 0;
 my $totcomtd    = 0;
 my $totavail    = 0;
 my @loop_budget = ();
@@ -149,22 +150,20 @@ foreach my $result (@results) {
     my $member      = GetMember( $result->{'budget_owner_id'} );
     my $member_full = $member->{'firstname'} . ' ' . $member->{'surname'} if $member;
 
-    $result->{'budget_owner'} = $member_full;
-    if ($result->{'budget_spent'}){
-       $result->{'budget_avail'} = $result->{'budget_amount'} - $result->{'budget_spent'};
-    }
-    else {
-       $result->{'budget_avail'} = $result->{'budget_amount'};
-    }
-    $result->{'budget_spent'} = GetBudgetSpent( $result->{'budget_id'} );
+    $result->{'budget_owner'}   = $member_full;
+    $result->{'budget_ordered'} = GetBudgetOrdered( $result->{'budget_id'} );
+    $result->{'budget_avail'}   = $result->{'budget_amount'} - $result->{'budget_spent'} - $result->{'budget_ordered'};
+    $result->{'budget_spent'}   = GetBudgetSpent( $result->{'budget_id'} );
 
-    $total    += $result->{'budget_amount'};
-    $totspent += $result->{'budget_spent'} if $result->{'budget_spent'};
-    $totavail += $result->{'budget_avail'};
+    $total      += $result->{'budget_amount'};
+    $totspent   += $result->{'budget_spent'};
+    $totordered += $result->{'budget_ordered'};
+    $totavail   += $result->{'budget_avail'};
 
-    $result->{'budget_amount'} = $num->format_price( $result->{'budget_amount'} );
-    $result->{'budget_spent'}  = $num->format_price( $result->{'budget_spent'} );
-    $result->{'budget_avail'}  = $num->format_price( $result->{'budget_avail'} );
+    $result->{'budget_amount'}  = $num->format_price( $result->{'budget_amount'} );
+    $result->{'budget_spent'}   = $num->format_price( $result->{'budget_spent'} );
+    $result->{'budget_ordered'} = $num->format_price( $result->{'budget_ordered'} );
+    $result->{'budget_avail'}   = $num->format_price( $result->{'budget_avail'} );
 
     #        my $spent_percent = ( $result->{'budget_spent'} / $result->{'budget_amount'} ) * 100;
     #        $result->{'budget_spent_percent'} = sprintf( "%00d", $spent_percent );
@@ -184,7 +183,8 @@ $template->param(
     branchname    => $branchname,
     budget        => $period->{budget_name},
     total         => $num->format_price(  $total ),
-    totspent      => $num->format_price($totspent ),
+    totspent      => $num->format_price( $totspent ),
+    totordered    => $num->format_price( $totordered ),
     totcomtd      => $num->format_price( $totcomtd ),
     totavail      => $num->format_price( $totavail ),
     suggestion    => $suggestion,
index c3376fe..df9ff2f 100644 (file)
@@ -45,7 +45,7 @@
             <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>
             <!-- TMPL_UNLESS NAME="basketcount" -->
-                <li><a id="newbasket" href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=<!-- TMPL_VAR name="id" -->">New Basket</a></li>
+                <li><a id="newbasket" href="/cgi-bin/koha/acqui/basketheader.pl?booksellerid=<!-- TMPL_VAR name="id" -->&op=add_form">New Basket</a></li>
             <!-- /TMPL_UNLESS -->
         <!-- TMPL_ELSE -->
             <li><a id="newbudget" href="/cgi-bin/koha/acqui/supplier.pl?op=enter">New Vendor</a></li>
index 5d793c0..6974433 100644 (file)
@@ -74,6 +74,7 @@
             <th>Owner</th>
             <th>Branch</th>
             <th>Amount</th>
+            <th>Ordered</th>
             <th>Spent</th>
             <th>Avail</th>
         </tr>
@@ -84,6 +85,7 @@
             <th>&nbsp;</th>
             <th>&nbsp;</th>
             <th align="right" ><!-- TMPL_VAR name="total" --></th>
+            <th align="right" ><!-- TMPL_VAR name="totordered" --></th>
             <th align="right" ><!-- TMPL_VAR name="totspent" --></th>
             <th align="right" ><!-- TMPL_VAR name="totavail" --></th>
         </tr>
                 <td align="center"><!-- TMPL_VAR name="budget_owner" --></td>
                 <td align="center"><!-- TMPL_VAR name="budget_branchname" --></td>
                 <td align="right" ><!-- TMPL_VAR name="budget_amount" --></td>
+                <td align="right" ><!-- TMPL_VAR name="budget_ordered" --></td>
                 <td align="right" ><!-- TMPL_VAR name="budget_spent" --></td>
                 <td align="right" ><!-- TMPL_VAR name="budget_avail" --></td>
             </tr>