big aqplan commit v2 for mantis:1177
authorMason James <mason.loves.sushi@gmail.com>
Thu, 2 Apr 2009 12:57:01 +0000 (01:57 +1300)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Wed, 30 Sep 2009 09:30:25 +0000 (11:30 +0200)
C4/Budgets.pm
acqui/pdfformat/example.pm
admin/aqplan.pl
koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
koha-tmpl/intranet-tmpl/prog/en/js/acq.js
koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqplan.tmpl

index a84c2fd..b739303 100644 (file)
@@ -62,10 +62,59 @@ BEGIN {
         &BudgetHasChildren
         &CheckBudgetParent
         &CheckBudgetParentPerm
+
+        &HideCols
+        &GetCols
        );
 }
 
 # ----------------------------BUDGETS.PM-----------------------------";
+
+
+sub HideCols {
+    my ( $authcat, @hide_cols ) = @_;
+    my $dbh = C4::Context->dbh;
+
+=c
+    my $sth = $dbh->prepare(
+        qq|
+        UPDATE aqbudgets_planning
+        SET display = 1 where authcat =  ? |
+    );
+    $sth->execute( $authcat );
+=cut
+
+    my $sth1 = $dbh->prepare(
+        qq|
+        UPDATE aqbudgets_planning SET display = 0 
+        WHERE authcat = ? 
+        AND  authvalue = ? |
+    );
+    foreach my $authvalue (@hide_cols) {
+#        $sth1->{TraceLevel} = 3;
+        $sth1->execute(  $authcat, $authvalue );
+    }
+}
+
+sub GetCols {
+    my ( $authcat, $authvalue ) = @_;
+
+    my $dbh = C4::Context->dbh;
+    my $sth = $dbh->prepare(
+        qq|
+        SELECT count(display) as cnt from aqbudgets_planning
+        WHERE  authcat = ? 
+        AND authvalue = ? and display  = 0   |
+    );
+
+#    $sth->{TraceLevel} = 3;
+    $sth->execute( $authcat, $authvalue );
+    my $res  = $sth->fetchrow_hashref;
+
+    return  $res->{cnt} > 0 ? 0: 1
+
+}
+
 sub CheckBudgetParentPerm {
     my ( $budget, $borrower_id ) = @_;
     my $depth = $budget->{depth};
@@ -192,7 +241,7 @@ sub GetBudgetsPlanCell {
     # get the estimated amount
     my $sth = $dbh->prepare( qq|
 
-        SELECT estimated_amount AS estimated FROM aqbudgets_planning
+        SELECT estimated_amount AS estimated, display FROM aqbudgets_planning
             WHERE budget_period_id = ? AND
                 budget_id = ? AND
                 authvalue = ? AND
@@ -203,7 +252,13 @@ sub GetBudgetsPlanCell {
                     $cell->{'authvalue'},
                     $cell->{'authcat'},
     );
-    my $estimated = $sth->fetchrow_array;
+
+
+    my $res  = $sth->fetchrow_hashref;
+  #  my $display = $res->{'display'};
+    my $estimated = $res->{'estimated'};
+
+
     return $actual, $estimated;
 }
 
index 9266a21..eaa1a49 100644 (file)
@@ -153,6 +153,10 @@ sub printorders {
 
 sub printbaskets {
     my ($pdf, $basketgroup, $hbaskets, $bookseller, $GSTrate, $orders) = @_;
+<<<<<<< HEAD:acqui/pdfformat/example.pm
+    $pdf->mediabox($height/mm, $width/mm);
+    my $page = $pdf->page();
+=======
     
     my $cur_format = C4::Context->preference("CurrencyFormat");
     my $num;
@@ -183,16 +187,24 @@ sub printbaskets {
     $text->translate(($width-40)/mm,  ($height-50)/mm);
     $text->text("".$basketgroup->{'id'});
     
+>>>>>>> paul:acqui/pdfformat/example.pm
     my $pdftable = new PDF::Table();
     my $abaskets;
     my $arrbasket;
     # header of the table
+<<<<<<< HEAD:acqui/pdfformat/example.pm
+    my @keys = ('Lot', 'Panier', 'Prix public', 'taux TVA', 'TVA', 'Remise', 'Total TTC');
+=======
     my @keys = ('Lot',  'Panier (N°)', 'Prix public TTC', 'Remise', 'Prix remisé','taux TVA', 'Total HT','TVA', 'Total TTC');
+>>>>>>> paul:acqui/pdfformat/example.pm
     for my $bkey (@keys) {
         push(@$arrbasket, $bkey);
     }
     my $grandtotal=0;
+<<<<<<< HEAD:acqui/pdfformat/example.pm
+=======
     my $grandgst=0;
+>>>>>>> paul:acqui/pdfformat/example.pm
     # calculate each basket total
     push(@$abaskets, $arrbasket);
     for my $basket (@$hbaskets) {
@@ -200,6 +212,25 @@ sub printbaskets {
         my ($total, $gst, $totallist) = (0, 0, 0);
         my $ords = $orders->{$basket->{basketno}};
         my $ordlength = @$ords;
+<<<<<<< HEAD:acqui/pdfformat/example.pm
+        for my $ord (@$ords[1..$ordlength]) {
+        warn "".@$ord[0]."=".@$ord[1]."=".@$ord[2]."=".@$ord[3]."=".@$ord[4]."=".@$ord[5]."=".@$ord[6]."=".@$ord[7]."=";
+            $total = $total + (@$ord[5] * @$ord[6]);
+            $gst   = $gst + ((@$ord[5] * @$ord[6]) * $GSTrate);
+            $totalttc = $totalttc+ @$ord[5] * @$ord[6] * (1 + $GSTrate) * (1 - $bookseller->{discount});
+        }
+        push(@$arrbasket, $basket->{contracname}, $basket->{basketname}, $total, $GSTrate, $gst, $bookseller->{discount}, $total + $gst);
+        push(@$abaskets, $arrbasket);
+    }
+    
+# height is width and width is height in this function, as the pdf is in landscape mode for the Tables.
+    my $text = $page->text(5/mm, 5/mm, ($height -10)/mm, ($width - 5)/mm);
+    $text->font( $pdf->corefont( 'Helvetica'), 8/mm );
+    my $txtstr = "REFERENCES DE COMMANDES DU BON DE COMMANDE N°".$basketgroup->{'id'};
+    my $txtwidth = $text->advancewidth($txtstr);
+    $text->translate(($height-$txtwidth*mm)/2/mm,  ($width-8-5)/mm);
+    $text->text($txtstr);
+=======
         foreach my $ord (@$ords) {
             $total += @$ord[5] * @$ord[7];
             $gst   += (@$ord[5] * @$ord[7]) * $GSTrate/(1+$GSTrate);
@@ -217,6 +248,7 @@ sub printbaskets {
     push @$arrbasket,'','','','Total',$num->format_price($grandtotal),'',$num->format_price($grandtotal-$grandgst), $num->format_price($grandgst),$num->format_price($grandtotal);
     push @$abaskets,$arrbasket;
     # height is width and width is height in this function, as the pdf is in landscape mode for the Tables.
+>>>>>>> paul:acqui/pdfformat/example.pm
 
     $pdftable->table($pdf, $page, $abaskets,
                                     x => 5/mm,
@@ -275,8 +307,20 @@ sub printhead {
 
     # print order info, on the default PDF
     $text->font( $pdf->corefont("Times", -encoding => "utf8"), 8/mm );
-    $text->translate(100/mm,  ($height-5-48)/mm);
-    $text->text($basketgroup->{'id'});
+    my $textstr = "Bon de commande N°  $basketgroup->{'id'}";
+    $txtwidth = $text->advancewidth( $textstr );
+    $text->translate(($width-$txtwidth*mm)/2/mm,  ($height-5-48)/mm);
+    $text->text($textstr);
+
+    $box->rectxy(5/mm, ($height - 60)/mm, ($width-5)/mm, ($height-230)/mm);
+    $box->stroke;
+    $box->restore();
+
+    $text->font( $pdf->corefont( 'Helvetica', -encoding => 'utf8', -encode => 'utf8'), 4/mm );
+    $textstr = $branch->{branchaddress1};
+    $txtwidth = $text->advancewidth( $textstr );
+    $text->translate(7/mm,  ($height - 60 - 6)/mm);
+    $text->text($textstr);
     
     # print the date
     my $today = C4::Dates->today();
@@ -316,12 +360,17 @@ sub printpdf {
     } ); # start with roman numbering
     # fill the 1st page (basketgroup information)
     printhead($pdf, $basketgroup, $bookseller, $branch);
+<<<<<<< HEAD:acqui/pdfformat/example.pm
+    printbaskets($pdf, $basketgroup, $baskets, $bookseller, $GST, $orders);
+    printorders($pdf, $basketgroup, $baskets, $orders);
+=======
     # fill the 2nd page (orders summary)
     printbaskets($pdf, $basketgroup, $baskets, $bookseller, $GST, $orders);
     # fill other pages (orders)
     printorders($pdf, $basketgroup, $baskets, $orders);
     # print something on each page (usually the footer, but you could also put a header
     printfooters($pdf);
+>>>>>>> paul:acqui/pdfformat/example.pm
     return $pdf->stringify;
 }
 
index 8eb95e1..787cc01 100755 (executable)
@@ -26,7 +26,7 @@ use List::Util qw/min/;
 use Date::Calc qw/Delta_YMD Easter_Sunday Today Decode_Date_EU/;
 use Date::Manip qw/ ParseDate UnixDate DateCalc/;
 use C4::Dates qw/format_date format_date_in_iso/;
-use Number::Format qw(format_price);      
+use Number::Format qw(format_price);
 use Text::CSV_XS;
 
 use C4::Acquisition;
@@ -62,6 +62,8 @@ my $cur    = GetCurrency;
 
 $template->param( period_button_only => 1 ) if $count == 0;
 
+
+
 # authcats_loop populates the YUI planning button
 my @auth_cats_loop            = GetBudgetAuthCats();
 my $budget_period_id          = $period->{'budget_period_id'};
@@ -71,6 +73,9 @@ my $budget_period_locked      = $period->{'budget_period_locked'};
 my $budget_period_description = $period->{'budget_period_description'};
 my $budget_period_dropbox     = GetBudgetPeriodsDropbox($budget_period_id );
 
+    ## ## @auth_cats_loop
+
+
 $template->param(
     budget_period_id          => $budget_period_id,
     budget_period_locked      => $budget_period_locked,
@@ -94,9 +99,18 @@ my $basename     = $input->param("basename");
 my $mime         = $input->param("MIME");
 my $del          = $input->param("sep");
 
+my $show_mine       = $input->param('show_mine') ;
+
+my @hide_cols      = $input->param('hide_cols');
+####  @hide_cols
+
+
+
+=c
 my $show_mine    = 1; #SHOW BY DEFAULT
 my $show         = $input->param('show'); # SET TO 1, BY A FORM SUMBIT
 $show_mine       = $input->param('show_mine') if $show == 1;
+=cut
 
 my $cur_format = C4::Context->preference("CurrencyFormat");
 my $num;
@@ -118,7 +132,7 @@ if ( $cur_format eq 'FR' ) {
     );
 }
 
-if ( $budget_period_locked == 1  && not defined  $show_actual ) { 
+if ( $budget_period_locked == 1  && not defined  $show_actual ) {
      $show_actual  = 1;
 }
 
@@ -127,6 +141,12 @@ $authcat = 'Asort1' if  not defined $authcat; # defaults to Asort if no authcat
 my $budget_id = $input->param('budget_id');
 my $op        = $input->param("op");
 
+my $budget_branchcode;
+
+
+#my $budgets_ref = GetBudgetHierarchy( $budget_period_id, $budget_branchcode );
+## ##  $budgets_ref
+
 my $budgets_ref = GetBudgetHierarchy( $budget_period_id, $show_mine?$template->{param_map}->{'USER_INFO'}[0]->{'branchcode'}:'', $show_mine?$template->{param_map}->{'USER_INFO'}[0]->{'borrowernumber'}:'' );
 
 # build categories list
@@ -168,23 +188,122 @@ my $CGISort;
 my @authvals;
 my %labels;
 
+
+    my @names = $input->param();
+
+# ------------------------------------------------------------
+if ( $op eq 'save' ) {
+
+
+    ### ---------------------  save
+
+    ####  @names
+
+
+    #get budgets
+    my ( @buds, @auth_values );
+    foreach my $n (@names) {
+        next if $n =~ m/^[^0-9]/;
+        my @moo = split( ',', $n );
+        push @buds, $moo[0];
+        push @auth_values, $moo[1];
+    }
+
+    #uniq buds and auth
+    my %seen;
+    @buds        = grep { !$seen{$_}++ } @buds;
+    @auth_values = grep { !$seen{$_}++ } @auth_values;
+    my @budget_ids;
+    my @budget_lines;
+
+    foreach my $budget (@buds) {
+        my %budget_line;
+        my @cells_line;
+        my %cell_hash;
+
+        foreach my $authvalue (@auth_values) {
+            # get actual stats
+            my $cell_name        = "$budget,$authvalue";
+            my $estimated_amount = $input->param("$cell_name");
+            my %cell_hash = (
+                estimated_amount => $estimated_amount,
+                authvalue        => $authvalue,
+                authcat          => $authcat,
+                budget_id        => $budget,
+                budget_period_id => $budget_period_id,
+            );
+            push( @cells_line, \%cell_hash );
+        }
+
+        %budget_line = (
+            lines => \@cells_line,
+        );
+        push( @budget_lines, \%budget_line );
+    }
+    my $plan = \@budget_lines;
+    ModBudgetPlan( $plan, $budget_period_id, $authcat );
+
+#### iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
+HideCols($authcat, @hide_cols);
+
+
+}
+
+
+# ------------------------------------------------------------
+
+
 if ( $authcat =~ m/^Asort/ ) {
 
+#### eeeee
     # ----------- copied from C4::Input::buildCGIsort()
-    my $query = qq{SELECT * FROM authorised_values WHERE category=? order by lib};
+   my $query = qq{ SELECT * FROM authorised_values WHERE category=? order by lib };
     my $sth   = $dbh->prepare($query);
-    $sth->execute($authcat);
+#### $query
+#    $sth->{TraceLevel} = 2;
+    $sth->execute($authcat  );
+
+=c
+    my $query = qq{ 
+
+SELECT * FROM authorised_values
+JOIN aqbudgets_planning  ON
+    (aqbudgets_planning.authvalue = authorised_values.authorised_value )
+WHERE (authcat = ?
+AND category = ?
+AND budget_period_id = ?
+AND display = 1 ) 
+ORDER BY lib   };
+
+
+    my $sth   = $dbh->prepare($query);
+#### $query
+    $sth->{TraceLevel} = 2;
+
+    $sth->execute($authcat, $authcat, $budget_period_id  );
+=cut
+
+
+#### qq
 
     if ( $sth->rows > 0 ) {
         for ( my $i = 0 ; $i < $sth->rows ; $i++ ) {
             my $results = $sth->fetchrow_hashref;
             push @authvals, $results->{authorised_value};
             $labels{ $results->{authorised_value} } = $results->{lib};
+ #          $labels{ $results->{display} } = 1 ;
+
         }
     }
     $sth->finish;
     @authvals = sort { $a <=> $b } @authvals;
 
+
+####  @authvals
+
+
+
+
 }
 elsif ( $authcat eq 'MONTHS' ) {
 
@@ -210,10 +329,23 @@ elsif ( $authcat eq 'MONTHS' ) {
 }
 
 elsif ( $authcat eq 'ITEMTYPES' ) {
+#### aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
     my $query = qq| SELECT itemtype, description FROM itemtypes |;
+=c
+    my $query = qq| SELECT * FROM aqbudgets_planning
+                    JOIN itemtypes ON (aqbudgets_planning.authvalue = itemtypes.itemtype)
+                    WHERE (authcat = 'itemtypes'
+                            AND budget_period_id = ? )     |;
+=cut
+
+
     my $sth   = $dbh->prepare($query);
-    $sth->execute();
+    $sth->{TraceLevel} = 3;
+
+
+    #$sth->execute( $budget_period_id  );
+    $sth->execute(  );
 
     if ( $sth->rows > 0 ) {
         for ( my $i = 0 ; $i < $sth->rows ; $i++ ) {
@@ -224,6 +356,14 @@ elsif ( $authcat eq 'ITEMTYPES' ) {
     }
     $sth->finish;
 
+
+            ####  @authvals
+
+
+
+
+
+
 } elsif ( $authcat eq 'BRANCHES' ) {
 
     my $query = qq| SELECT branchcode, branchname FROM branches |;
@@ -240,17 +380,35 @@ elsif ( $authcat eq 'ITEMTYPES' ) {
     $sth->finish;
 }
 
+####     @authvals
+####     %labels
+
+
+
 my @authvals_row;
+my $i=1;
 foreach my $val (@authvals) {
     my %auth_hash;
     $auth_hash{val} =   $labels{$val};
+    $auth_hash{code} =   $val;
+    $auth_hash{colnum} =   $i++;
+
+    # display lookup
+    $auth_hash{display} = GetCols( $authcat,  $auth_hash{code});
+
     push( @authvals_row, \%auth_hash );
 }
+#### ddddddddddddd
+#### @authvals_row
+
+
+
+
+
+
+
+
 
-# ------------------------------------------------------------
-if ( $op eq 'save' ) {
-    ### ---------------------  save
-    my @names = $input->param();
 
     #get budgets
     my ( @buds, @auth_values );
@@ -261,38 +419,7 @@ if ( $op eq 'save' ) {
         push @auth_values, $2;
     }
 
-    #uniq buds and auth
-    my %seen;
-    @buds        = grep { !$seen{$_}++ } @buds;
-    @auth_values = grep { !$seen{$_}++ } @auth_values;
-    my @budget_ids;
-    my @budget_lines;
 
-    foreach my $budget (@buds) {
-        my %budget_line;
-        my @cells_line;
-        my %cell_hash;
-        foreach my $authvalue (@auth_values) {
-            # get actual stats
-            my $cell_name        = "$budget,$authvalue";
-            my $estimated_amount = $input->param("$cell_name");
-            my %cell_hash = (
-                estimated_amount => $estimated_amount,
-                authvalue        => $authvalue,
-                authcat          => $authcat,
-                budget_id        => $budget,
-                budget_period_id => $budget_period_id,
-            );
-            push( @cells_line, \%cell_hash );
-        }
-        %budget_line = (
-            lines => \@cells_line,
-        );
-        push( @budget_lines, \%budget_line );
-    }
-    my $plan = \@budget_lines;
-    ModBudgetPlan( $plan, $budget_period_id, $authcat );
-}
 # ------------------------------------------------------------
 #         DEFAULT DISPLAY BEGINS
 
@@ -320,6 +447,10 @@ my $CGIsepChoice = CGI::scrolling_list(
 
 my ( @budget_lines, %cell_hash );
 
+
+
+
+
 foreach my $budget (@budgets) {
     my $budget_lock;
 
@@ -342,10 +473,12 @@ foreach my $budget (@budgets) {
             && $budget->{'sort2_authcat'} ne $authcat );
     }
 
-    my %budget_line;
+    my %budget_line; # each row of the  table
     my @cells_line;
     my $actual_spent;
     my $estimated_spent;
+
+    my $i = 0;
     foreach my $authvalue (@authvals) {
 
         # get actual stats
@@ -359,14 +492,22 @@ foreach my $budget (@budgets) {
             budget_lock      => $budget_lock,
         );
 
-        my ( $actual, $estimated ) = GetBudgetsPlanCell( \%cell, $period, $budget );
+        my ( $actual, $estimated, $display ) = GetBudgetsPlanCell( \%cell, $period, $budget );
         $cell{actual_amount}    = sprintf( "%.2f", $actual );
         $cell{estimated_amount} = sprintf( "%.2f", $estimated );
+        $cell{display}          = $authvals_row[$i]{display};
+        $cell{colnum}           = $i;
+
         $actual_spent    += $cell{actual_amount};
         $estimated_spent += $cell{estimated_amount};
+
+
         push( @cells_line, \%cell );
+        $i++;
     }
 
+
+
     #     lines => \@cells_line,
     my $budget_act_remain = $budget->{budget_amount} - $actual_spent;
     my $budget_est_remain = $budget->{budget_amount} - $estimated_spent;
@@ -379,9 +520,12 @@ foreach my $budget (@budgets) {
         budget_alloc            => $budget->{budget_alloc},
         budget_act_remain       => sprintf( "%.2f", $budget_act_remain ),
         budget_est_remain       => sprintf( "%.2f", $budget_est_remain ),
-        budget_id               => $budget->{budget_id}
+        budget_id               => $budget->{budget_id},
+        budget_lock             => $budget_lock,
     );
 
+
+
     $budget_line{est_negative} = '1' if $budget_est_remain < 0;
     $budget_line{est_positive} = '1' if $budget_est_remain > 0;
     $budget_line{act_negative} = '1' if $budget_act_remain < 0;
@@ -390,6 +534,9 @@ foreach my $budget (@budgets) {
     # skip if active set , and spent == 0
     next if ( $show_active == '1' && ( $actual_spent == 0 ) );
 
+
+    ### %budget_lin
+
     push( @budget_lines, \%budget_line );
 }
 
@@ -399,6 +546,7 @@ if ( $output eq "file" ) {
 }
 
     ## ## @budget_lines
+
 $template->param(
     authvals_row              => \@authvals_row,
     budget_lines              => \@budget_lines,
@@ -409,15 +557,36 @@ $template->param(
     show_active               => $show_active,
     show_actual               => $show_actual,
     show_percent              => $show_percent,
-    show_mine                  => $show_mine,
+    show_mine                 => $show_mine,
     cur                       => $cur->{symbol},
     cur_format                => $cur_format,
     CGIextChoice              => $CGIextChoice,
     CGIsepChoice              => $CGIsepChoice,
+
+    authvals              => \@authvals_row,
+    hide_cols_loop              => \@hide_cols
 );
+#### uuuuuuuuuuu
+
+
 
 output_html_with_http_headers $input, $cookie, $template->output;
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 sub _print_to_csv {
     my ( $header, $results ) = @_;
 
index a2f8cc2..c05afa3 100644 (file)
@@ -231,15 +231,14 @@ table {
        border-right : 1px solid #BCBCBC;
 }
 
-table.borderless {
-    border-collapse : separate;
-    border: 0 none;
+table.invis{
+       border : white;
 }
-
-#label-search-results {
-        width: 700px;
+table.invis tr,table.invis td {
+       border : white;
 }
 
+
 td, th {
        border-bottom : 1px solid #BCBCBC;
        border-left : 1px solid #BCBCBC;
index 88061fc..84c9f86 100644 (file)
@@ -966,3 +966,61 @@ function checkBudgetParent(budgetId, newBudgetParent) {
      }
 }
 
+
+function addColumn(p_sType, p_aArgs, p_oValue)
+{
+    var allRows = document.getElementById('plan').rows;
+    var colnum  = p_oValue[0];
+    var code   = p_oValue[1];
+    var colnum  = new Number(colnum);
+
+    for (var i=0; i<allRows.length; i++) {
+            var allCells  = allRows[i].cells;
+            allCells[colnum+1].style.display="table-cell";
+    }
+
+// make a menuitem object
+    var hids = document.getElementsByName("hide_cols")
+    for (var i=0; i<hids.length; i++) {
+        if (hids[i].value == code) {
+            var x =  hids[i];
+            x.parentNode.removeChild(x)    // sigh...
+            break;
+        }
+    }
+}
+
+
+function delColumn(n, code)
+{
+    var allRows = document.getElementById('plan').rows;
+
+// find index
+    var index;
+    var nn  = new Number(n);
+    var code   = code ;
+    for (var i=0; i<allRows.length; i++) {
+        var allCells  = allRows[i].cells;
+        allCells[nn+1].style.display="none";
+    }
+
+    var r = 0;
+    var hids = document.getElementsByName("hide_cols")
+    for (var i=0; i<hids.length; i++) {
+        if (hids[i].value == code) {
+            r = 1;
+            break;
+        }
+    }
+
+    if (r == 0 ) {
+        // add hide_col to form
+        var el = document.createElement("input");
+        el.setAttribute("type", 'hidden' );
+        el.setAttribute("value", code);
+        el.setAttribute("name", 'hide_cols');
+        document.getElementById("hide_div").appendChild(el);
+    }
+}
+
+
index af170a6..dfbef4f 100644 (file)
@@ -2,19 +2,32 @@
 <title>
 Budget planning
 </title>
+<head>
 <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
 <!-- TMPL_INCLUDE NAME="calendar.inc" -->
-
 </head>
 <body>
 <!-- TMPL_INCLUDE NAME="header.inc" -->
 <!-- TMPL_INCLUDE NAME="budgets-admin-search.inc" -->
 
+<link href="<!-- TMPL_VAR NAME="yuipath" -->/reset/reset.css" rel="stylesheet" type="text/css" />
+<link href="<!-- TMPL_VAR NAME="yuipath" -->/fonts/fonts.css" rel="stylesheet" type="text/css" />
+<link href="<!-- TMPL_VAR NAME="yuipath" -->/menu/assets/menu.css" rel="stylesheet" type="text/css" />
+<link href="<!-- TMPL_VAR NAME="yuipath" --> /container/assets/skins/sam/container.css"  rel="stylesheet" type="text/css" />
+
+<script  src="<!-- TMPL_VAR NAME="yuipath" -->/yahoo/yahoo.js" type="text/javascript"></script>
+<script  src="<!-- TMPL_VAR NAME="yuipath" -->/event/event.js" type="text/javascript"></script>
+<script  src="<!-- TMPL_VAR NAME="yuipath" -->/dom/dom.js" type="text/javascript"></script>
+<script  src="<!-- TMPL_VAR NAME="yuipath" -->/menu/menu.js" type="text/javascript"></script>
+<script  src="<!-- TMPL_VAR NAME="yuipath" -->/container/menu.js" type="text/javascript"></script>
+<script  src="<!-- TMPL_VAR NAME="yuipath" -->/yahoo-dom-event/yahoo-dom-event.js"  type="text/javascript"></script>
+
+
 <script type="text/javascript" src="<!-- TMPL_VAR NAME='themelang' -->/js/acq.js"></script>
 <script type="text/javascript">
-// ######################################################################
+// ---------------------------------------------------------------------
 // Javascript
-// ######################################################################
+// ---------------------------------------------------------------------
     function Check(f) {
             var ok=1;
             var _alertString="";
@@ -30,7 +43,15 @@ Budget planning
             }
 
             if (_alertString.length==0) {
-                    document.Aform.submit();
+
+                var op  = document.createElement('input');
+                op.setAttribute("type","hidden");
+                op.setAttribute("name","op");
+                op.setAttribute("value","save");   //ohh the pain...
+
+                document.Aform.appendChild(op);
+                document.Aform.submit()
+
             } else {
                     alertString2  = _("Form not submitted because of the following problem(s)");
                     alertString2 += "\n------------------------------------------------------------------------------------\n";
@@ -38,8 +59,34 @@ Budget planning
                     alert(alertString2);
             }
     }
+
+
+YAHOO.util.Event.onAvailable("popmenu", function () {
+
+    var itemData  = new Array();
+    table = document.getElementById('plan') 
+    tableTmp =  table.cloneNode(true); 
+    tableTmp.id = 'planTmp';
+
+    <!-- TMPL_LOOP NAME="authvals_row" -->
+        itemData.push( {   text: "<!-- TMPL_VAR NAME="val" -->",  onclick: { fn: addColumn, obj:  ["<!-- TMPL_VAR NAME="colnum" -->",  "<!-- TMPL_VAR NAME="code" -->"]    }    }     );
+
+    <!-- /TMPL_LOOP -->
+    oMenu = new YAHOO.widget.Menu("basicmenu",
+            {  position: "dynamic", itemdata: itemData , clicktohide  : "true" , context:["popmenu","tl","tr"] }
+    );
+
+   oMenu.render("popmenu");
+   YAHOO.util.Event.addListener("add_popmenu_item", "click", oMenu.show, null, oMenu);
+
+// oMenu.removeItem(2);   // TODO.....
+
+});
+
 </script>
 
+
+
 <div id="breadcrumbs">
     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
     <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo;
@@ -52,125 +99,163 @@ Budget planning
 <div id="yui-main">
 <div class="yui-b">
 
-<!-- TMPL_INCLUDE NAME="budgets-admin.inc" -->    
 
-<h1>Planning for <!-- TMPL_VAR NAME="budget_period_description" --> by <!-- TMPL_VAR NAME="authcat" --></h1>
+<!-- TMPL_INCLUDE NAME="budgets-admin.inc" -->
+
 <br>
 
-<form method="post" action="/cgi-bin/koha/admin/aqplan.pl">
-    <fieldset>
-    <legend>Planning options</legend>
-     <li><label for="budget_period_dropbox">Select budget period:</label>
-     <!-- TMPL_VAR name="budget_period_dropbox" -->
-    </li>
+<form method="post" id='Aform' name="Aform"  action="/cgi-bin/koha/admin/aqplan.pl">
 
-    <li><label for="authcat_dropbox"  > Select planning type:</label>
-    <!-- TMPL_VAR NAME="authcat_dropbox" -->
-    </li>
-
-    <li>
+<fieldset style=" border:2px solid #EEEEEE; " >
+<legend>Planning for <!-- TMPL_VAR NAME="budget_period_description" --> by <!-- TMPL_VAR NAME="authcat" --></legend>
+    <table class="invis" >
+    <tr><td>
     <!-- TMPL_IF NAME="show_mine" -->
         <input type="checkbox" id="show_mine"  name="show_mine" value="1" checked="checked" />
-    <!-- TMPL_ELSE -->  
+    <!-- TMPL_ELSE -->
         <input type="checkbox" id="show_mine"  name="show_mine" value="1"  />
-    <!-- /TMPL_IF -->  
+    <!-- /TMPL_IF -->
     <label for="show_mine">Show my budgets only</label>
-    </li>
-    <input type="hidden" name="show" value="1"  -->
+    </td><td>
+
+     <label for="budget_period_dropbox">Select budget period:</label>
+     <!-- TMPL_VAR name="budget_period_dropbox" -->
+    </td></tr>
 
-    <li>
+    <tr><td>
     <!-- TMPL_IF NAME="show_active" -->
         <input type="checkbox" id="show_active" name="show_active" value="1" checked="checked" />
-    <!-- TMPL_ELSE -->  
+    <!-- TMPL_ELSE -->
         <input type="checkbox" id="show_active" name="show_active" value="1" />
-        <!-- /TMPL_IF --> 
+        <!-- /TMPL_IF -->
     <label for="show_active">Show active budgets only</label>
-    </li>
+    </td><td>
+
+    <label for="authcat_dropbox"  > Select planning type:</label>
+    <!-- TMPL_VAR NAME="authcat_dropbox" -->
+    </td></tr>
 
     <!-- TMPL_UNLESS  name="budget_period_locked" -->
-        <li>
-        <label for="show_actual">Show actual/estimated values:</label>
+    <tr><td>
         <!-- TMPL_IF NAME="show_actual" -->
-            <input type="checkbox" name="show_actual" value="1"   checked="checked" />
-        <!-- TMPL_ELSE -->  
-            <input type="checkbox" name="show_actual" value="1"  />
+            <input type="checkbox"    id="show_actual"   name="show_actual" value="1"   checked="checked" />
+        <!-- TMPL_ELSE -->
+            <input type="checkbox" id="show_actual" name="show_actual" value="1"  />
         <!-- /TMPL_IF -->
-        </li>
+        <label for="show_actual">Show actual/estimated values:</label>
+    </td>
+
+    <td align="right">
+     <input type="submit" name="option_submit" value="Select" />
+    </td>
+    </tr>
     <!-- /TMPL_UNLESS -->
 
-    <li>
-    <input type="hidden" name="budget_period_id" value="<!-- TMPL_VAR NAME="budget_period_id" -->" />
-     <input style="position:relative; left:180px"   type="submit" value="Select" />
-    </li>
     <br>
-    </fieldset>
-</form>
 
-<form method="post" name="Aform"  ction="/cgi-bin/koha/admin/aqplan.pl">
-    <input type="hidden" name="budget_period_id" value="<!-- TMPL_VAR NAME="budget_period_id" -->" />
+    </td></tr>
+    </table>
+</fieldset>
+
+<br>
+
+<!-- --------------------------------------------------------- -->
+
+    <!-- TMPL_IF NAME="budget_lines" -->
 
-    <table>
+    <table id="plan" width="100%">
+    <thead>
     <tr>
     <th>Budget name</th>
     <th>Budget total</th>
+
     <!-- TMPL_LOOP NAME="authvals_row" -->
-        <th><!-- TMPL_VAR NAME="val" --></th>
+         <th id="<!-- TMPL_VAR NAME="code" -->"   style="text-align: center;   
+    <!-- TMPL_UNLESS NAME="display" --> display:none;  <!-- /TMPL_UNLESS -->
+
+    class="<!-- TMPL_VAR NAME="colnum" -->" >
+    <!-- TMPL_VAR NAME="val" -->&nbsp;<span class="buttonPlus" onclick="delColumn('<!-- TMPL_VAR NAME="colnum" -->', '<!-- TMPL_VAR NAME="code" -->')"  > - &nbsp;</span></th>
+
     <!-- /TMPL_LOOP -->
-    <th >Budget remaining</th>
 
-    <!-- TMPL_UNLESS Name="budget_period_locked" -->
-        <th></th>
-    <!-- /TMPL_UNLESS -->
+    <th >Budget remaining    </th>
+
+    <th id='popmenu' style=" text-align: center;" >
+    <span id="add_popmenu_item"    class="buttonPlus" > + </span></th>
     </tr>
+    </thead>
 
+    <tbody>
     <!-- TMPL_LOOP NAME="budget_lines" -->
-        <tr>
+            <!-- TMPL_IF Name="budget_lock" -->
+        <tr  class="highlight"  > 
+            <!--TMPL_ELSE -->
+        <tr > 
+            <!--/TMPL_IF -->
+
         <td align='left'><!-- TMPL_VAR NAME="budget_name_indent"--></td>
-        <td align='center'><span id='budget_tot_formatted" -->'><!-- TMPL_VAR NAME="budget_amount_formatted"--></span></td>
+        <td align='right'><span id='budget_tot_formatted" -->'><!-- TMPL_VAR NAME="budget_amount_formatted"-->&nbsp;</span></td>
 
         <!-- NEXT DIV ELEMENT IS USED BY JS FOR CALC-ING AUTO-FILL AND ESTIMATED AMOUNTS -->
         <div style="display:none;" id='budget_tot_<!-- TMPL_VAR NAME="budget_id" -->'><!-- TMPL_VAR NAME="budget_amount"--></div>
+
         <!-- TMPL_LOOP NAME="lines"    -->
+            <td 
+            <!-- TMPL_UNLESS Name="display" --> style="display:none;"<!-- /TMPL_UNLESS -->
+                    class="<!-- TMPL_VAR NAME="colnum"-->"  >  
+            <table class="invis" width="100%">
+                <tr>
+                    <!-- TMPL_IF Name="show_actual" -->
+                        <td   width="50%"  align="right" ><!-- TMPL_VAR NAME="actual_amount" --></td>
+                    <!--/TMPL_IF -->
+                <td align="right">
 
-            <td align='center'>
-            <span>
-            <!-- TMPL_IF Name="show_actual" -->
-                <!-- TMPL_VAR NAME="actual_amount" --> /
-            <!--/TMPL_IF -->
-            <!-- TMPL_IF Name="budget_period_locked" -->
-                <!-- TMPL_VAR NAME="estimated_amount" -->
-            <!--TMPL_ELSIF  Name="budget_lock" -->
-                <!-- TMPL_VAR NAME="estimated_amount" -->
-            <!--TMPL_ELSE -->
-            <input type="text" style="text-align: right;" size='6' name='<!-- TMPL_VAR NAME="cell_name"-->'  value="<!-- TMPL_VAR NAME="estimated_amount" -->"  id='<!-- TMPL_VAR NAME="budget_id"-->' class='<!-- TMPL_VAR NAME="budget_id"-->' onchange="calcTotalRow(this);" >
-            <!--/TMPL_IF -->
+                <!--TMPL_IF  Name="budget_lock" -->
+                    <!-- TMPL_VAR NAME="estimated_amount" -->uu&nbsp;
+                    <input type="hidden" style="text-align: right;"  name='<!-- TMPL_VAR NAME="cell_name"-->' value="<!-- TMPL_VAR NAME="estimated_amount" -->"   >
+                <!--TMPL_ELSE -->
+                    <input type="text" style="text-align: right;  width:90%; " size='6' name='<!-- TMPL_VAR NAME="cell_name"-->'  value="<!-- TMPL_VAR NAME="estimated_amount" -->"  id='<!-- TMPL_VAR NAME="budget_id"-->' class='<!-- TMPL_VAR NAME="budget_id"-->' onchange="calcTotalRow(this);" >
+                <!--/TMPL_IF -->
 
-            </span>
+                </td></tr>
+            </table>
             </td>
         <!-- /TMPL_LOOP -->
 
-        <td align="center">
-
-        <!-- TMPL_IF Name="show_actual" -->
-            <span
+        <td>
+        <table class="invis" width="100%">
+            <tr>
+            <td width="50%"    align="right"  
+       <!-- TMPL_IF Name="show_actual" -->
             <!-- TMPL_IF NAME="act_negative" --> style="color: red;" <!--/TMPL_IF -->
                 <!-- TMPL_IF NAME="act_positive" --> style="color: green;" <!--/TMPL_IF --> >
                 <!-- TMPL_VAR NAME="budget_act_remain"-->
-            </span> /
         <!-- /TMPL_IF -->
-        <span
+            </td>
+
+            <td width="50%"    align="right"  
         <!-- TMPL_IF NAME="est_negative" --> style="color: red;" <!--/TMPL_IF -->
         <!-- TMPL_IF NAME="est_positive" --> style="color: green;" <!--/TMPL_IF -->
-        name="est_total" id='budget_est_<!-- TMPL_VAR NAME="budget_id"-->'><!-- TMPL_VAR NAME="budget_est_remain"-->
-        </span></td>
-        <!-- TMPL_UNLESS Name="budget_period_locked" -->
-            <td><input type="button"  onclick="autoFillRow('<!-- TMPL_VAR NAME="budget_id"-->')" value="Auto-fill row"/> </td>
-        <!-- /TMPL_UNLESS  -->
+        name="est_total" id='budget_est_<!-- TMPL_VAR NAME="budget_id"-->'>  <!-- TMPL_VAR NAME="budget_est_remain"-->&nbsp;    
+            </td>
+            </tr>
+        </table>
+        </td>
+
+        <td align="center">
+             <!-- TMPL_UNLESS Name="budget_lock" -->
+                    <input type="button"  onclick="autoFillRow('<!-- TMPL_VAR NAME="budget_id"-->')" value="Auto-fill row"/>
+            <!-- TMPL_ELSE  -->
+             <div style="color:red;">LOCKED</div>
+            <!-- /TMPL_UNLESS  -->
+        </td>
         </tr>
     <!-- /TMPL_LOOP -->
+    <tbody>
     </table>
+
     <!-- TMPL_IF NAME="show_actual" -->
-        <span><b>Cells contain 'Actual / Estimated' values.</b></span><br>
+        <span><b>Each cell contain both actual and estimated values.</b></span><br>
     <!-- TMPL_ELSE -->
         <span><b>Cells contain estimated values only.</b></span><br>
     <!-- /TMPL_IF -->
@@ -179,9 +264,20 @@ Budget planning
         <!-- <input STYLE="background: gray;"   type="submit" value="Save" disabled='disabled'/> -->
     <!-- TMPL_ELSE -->
         <input type="button"  onclick="Check(this.form)" value="Save"/>
-        <input type="hidden" name="op" value="save"/>
     <!-- /TMPL_IF -->
-        <input type="hidden" name="authcat" value="<!-- TMPL_VAR NAME="authcat"-->"/>
+
+
+<div id='hide_div'>
+    <!-- TMPL_LOOP NAME="authvals_row" -->
+
+     <!-- TMPL_UNLESS Name="display" -->
+        <input type="hidden" value="<!-- TMPL_VAR NAME="code" -->"  name="hide_cols"/>
+     <!-- /TMPL_UNLESS -->
+    <!-- /TMPL_LOOP -->
+
+ </div>
+
+
 </form>
 
 <form method="post" action="/cgi-bin/koha/admin/aqplan.pl">
@@ -198,6 +294,11 @@ Budget planning
     </fieldset>
 </form>
 
+        <!-- TMPL_ELSE         -->
+No budgets to display for this search criteria
+        <!-- /TMPL_IF  -->
+
+
 </div>
 </div>
 <div class="yui-b">