From 5022a8583a9a77394d084402c00f622ed7769350 Mon Sep 17 00:00:00 2001 From: Mason James Date: Fri, 3 Apr 2009 01:57:01 +1300 Subject: [PATCH] big aqplan commit v2 for mantis:1177 --- C4/Budgets.pm | 59 +++- acqui/pdfformat/example.pm | 53 +++- admin/aqplan.pl | 257 +++++++++++++++--- .../prog/en/css/staff-global.css | 11 +- koha-tmpl/intranet-tmpl/prog/en/js/acq.js | 58 ++++ .../prog/en/modules/admin/aqplan.tmpl | 249 ++++++++++++----- 6 files changed, 559 insertions(+), 128 deletions(-) diff --git a/C4/Budgets.pm b/C4/Budgets.pm index a84c2fde6e..b739303887 100644 --- a/C4/Budgets.pm +++ b/C4/Budgets.pm @@ -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; } diff --git a/acqui/pdfformat/example.pm b/acqui/pdfformat/example.pm index 9266a21c07..eaa1a498c2 100644 --- a/acqui/pdfformat/example.pm +++ b/acqui/pdfformat/example.pm @@ -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; } diff --git a/admin/aqplan.pl b/admin/aqplan.pl index 8eb95e14a7..787cc0172b 100755 --- a/admin/aqplan.pl +++ b/admin/aqplan.pl @@ -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 ) = @_; diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css index a2f8cc2f09..c05afa31ae 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css +++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css @@ -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; diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js b/koha-tmpl/intranet-tmpl/prog/en/js/acq.js index 88061fc06a..84c9f86d9b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/acq.js @@ -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 Budget planning + - +/reset/reset.css" rel="stylesheet" type="text/css" /> +/fonts/fonts.css" rel="stylesheet" type="text/css" /> +/menu/assets/menu.css" rel="stylesheet" type="text/css" /> + /container/assets/skins/sam/container.css" rel="stylesheet" type="text/css" /> + + + + + + + + + + +