[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[4718] branches/1.3
- Subject: SF.net SVN: ledger-smb:[4718] branches/1.3
- From: ..hidden..
- Date: Fri, 18 May 2012 11:28:29 +0000
Revision: 4718
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4718&view=rev
Author: einhverfr
Date: 2012-05-18 11:28:28 +0000 (Fri, 18 May 2012)
Log Message:
-----------
Added missing csv template for pricelists. Added ods pricelist support
Modified Paths:
--------------
branches/1.3/Changelog
branches/1.3/LedgerSMB/Template/ODS.pm
branches/1.3/UI/Contact/pricelist.html
Added Paths:
-----------
branches/1.3/UI/Contact/pricelist.csv
branches/1.3/UI/Contact/pricelist.odst
branches/1.3/UI/lib/dynatable.odst
Modified: branches/1.3/Changelog
===================================================================
--- branches/1.3/Changelog 2012-05-18 07:12:53 UTC (rev 4717)
+++ branches/1.3/Changelog 2012-05-18 11:28:28 UTC (rev 4718)
@@ -2,6 +2,10 @@
Initial Release: Monday, Oct 12 2011
Supported Presently
+Changelog for 1.3.18
+* Fixed missing template for CSV pricelists (Chris T)
+* Added ODS pricelists (Chris T)
+
Changelog for 1.3.17
* Address now shows on ECA selection screen (Erik H)
* Taxes::Simple now respects min/max values based on subtotal (Chris T)
Modified: branches/1.3/LedgerSMB/Template/ODS.pm
===================================================================
--- branches/1.3/LedgerSMB/Template/ODS.pm 2012-05-18 07:12:53 UTC (rev 4717)
+++ branches/1.3/LedgerSMB/Template/ODS.pm 2012-05-18 11:28:28 UTC (rev 4718)
@@ -54,7 +54,10 @@
use XML::Twig;
use OpenOffice::OODoc;
use LedgerSMB::Template::TTI18N;
+use LedgerSMB::Sysconfig;
+$OpenOffice::OODoc::File::WORKING_DIRECTORY = $LedgerSMB::Sysconfig::tempdir;
+
my $binmode = undef;
binmode STDOUT, ':bytes';
binmode STDERR, ':bytes';
@@ -63,7 +66,11 @@
my $ods;
my $rowcount;
my $currcol;
+my $maxrows;
+my $maxcols;
my %celltype;
+my $sheetnum = -1;
+my $sheetname;
# SC: The elements of the style table for regular styles and stack are
# arrays where the stack name is the first element and the style
@@ -119,16 +126,20 @@
);
sub _worksheet_handler {
+ $sheetnum += 1;
$rowcount = -1;
$currcol = 0;
my $rows = $_->{att}->{rows};
my $columns = $_->{att}->{columns};
$rows ||= 1000;
$columns ||= 52;
+ $maxrows = $rows;
+ $maxcols = $columns;
my $sheet;
if ($_->is_first_child) {
$sheet = $ods->getTable(0, $rows, $columns);
$ods->renameTable($sheet, $_->{att}->{name});
+ $sheetname = $_->{att}->{name};
} else {
$sheet = $ods->appendTable($_->{att}->{name}, $rows, $columns);
}
@@ -140,7 +151,8 @@
}
sub _cell_handler {
- my $cell = $ods->getCell(-1, $rowcount, $currcol);
+ $ods->expandTable($sheetname, $maxrows, $maxcols);
+ my $cell = $ods->getCell($sheetname, $rowcount, $currcol);
if (@style_stack and $celltype{$style_stack[0][0]}) {
$ods->cellValueType($cell, $celltype{$style_stack[0][0]}[0]);
@@ -152,7 +164,9 @@
$ods->cellValueType($cell, 'float');
}
}
- $ods->cellValue($cell, $_->{att}->{text});
+ print STDERR "Calling cellValue($sheetname, $rowcount, $currcol, $_->{att}->{text})\n";
+ $ods->cellValue($sheetname, $rowcount, $currcol, $_->{att}->{text});
+ print STDERR "The above cell is now set to " . $ods->getCellValue($sheetnum, $rowcount, $currcol) . "\n";
if (@style_stack) {
$ods->cellStyle($cell, $style_stack[0][0]);
}
@@ -160,7 +174,7 @@
}
sub _formula_handler {
- my $cell = $ods->getCell(-1, $rowcount, $currcol);
+ my $cell = $ods->getCell($sheetnum, $rowcount, $currcol);
if (@style_stack and $celltype{$style_stack[0][0]}) {
$ods->cellValueType($cell, $celltype{$style_stack[0][0]}[0]);
@@ -762,8 +776,7 @@
sub _ods_process {
my ($filename, $template) = @_;
-
- $ods = ooDocument(file => $filename, create => 'spreadsheet');
+ $ods = ooDocument(file => "$filename", create => 'spreadsheet');
my $parser = XML::Twig->new(
start_tag_handlers => {
@@ -789,6 +802,15 @@
);
$parser->parse($template);
$parser->purge;
+##############
+use Data::Dumper;
+ my $d = Data::Dumper->new( [$ods] );
+ $d->Sortkeys(1);
+
+ open( FH, '>', "/tmp/ods" ) or die $!;
+ print FH $d->Dump();
+ close(FH);
+###########
$ods->save;
}
Added: branches/1.3/UI/Contact/pricelist.csv
===================================================================
--- branches/1.3/UI/Contact/pricelist.csv (rev 0)
+++ branches/1.3/UI/Contact/pricelist.csv 2012-05-18 11:28:28 UTC (rev 4718)
@@ -0,0 +1,49 @@
+<?lsmb- PROCESS 'dynatable.csv' -?>
+<?lsmb-
+ columns = [
+ { col_id = 'parts_id',
+ type = 'hidden' },
+ { col_id = 'int_partnumber'
+ name = text('Partnumber')
+ type = 'text'
+ },
+ { col_id = 'description'
+ name = text('Description')
+ type = 'text'
+ } ];
+ IF account_class == 1;
+ columns.push(
+ {col_id = 'lastcost'
+ name = text('Last Cost')
+ type = 'text_input'},
+ {col_id = 'partnumber',
+ name = text('Vendor Partnumber')
+ type = 'text_input'},
+ {col_id = 'leadtime',
+ name = text('Lead Time')
+ type = 'input_text'}
+ );
+
+ ELSE;
+
+ columns.push(
+ {col_id = 'sellprice'
+ name = text('Sell Price')
+ type = 'input_text'},
+ {col_id = 'validfrom',
+ name = text('Valid From')
+ type = 'input_text'},
+ {col_id = 'validto',
+ name = text('Valid To')
+ type = 'input_text'},
+ );
+
+ END;
+ columns.push({col_id = 'currency',
+ name = text('Currency'),
+ type = 'text'},
+ );
+ PROCESS dynatable
+ tbody = { rows = pricematrix }
+
+-?>
Modified: branches/1.3/UI/Contact/pricelist.html
===================================================================
--- branches/1.3/UI/Contact/pricelist.html 2012-05-18 07:12:53 UTC (rev 4717)
+++ branches/1.3/UI/Contact/pricelist.html 2012-05-18 11:28:28 UTC (rev 4718)
@@ -91,6 +91,12 @@
?> <a href="customer.pl?action=pricelist&format=XLS&credit_id=<?lsmb
credit_id ?>&entity_id=<?lsmb entity_id
?>">[<?lsmb text('XLS') ?>]</a>
+<?lsmb END;
+
+IF FORMATS.grep('ODS').size()
+?> <a href="customer.pl?action=pricelist&format=ODS&credit_id=<?lsmb
+ credit_id ?>&entity_id=<?lsmb entity_id
+ ?>">[<?lsmb text('ODS') ?>]</a>
<?lsmb END ?>
<a href="customer.pl?action=pricelist&format=CSV&credit_id=<?lsmb
credit_id ?>&entity_id=<?lsmb entity_id
Added: branches/1.3/UI/Contact/pricelist.odst
===================================================================
--- branches/1.3/UI/Contact/pricelist.odst (rev 0)
+++ branches/1.3/UI/Contact/pricelist.odst 2012-05-18 11:28:28 UTC (rev 4718)
@@ -0,0 +1,54 @@
+<workbook>
+<?lsmb
+ PROCESS 'dynatable.odst';
+ columns = [
+ { col_id = 'parts_id',
+ type = 'hidden' },
+ { col_id = 'int_partnumber'
+ name = text('Partnumber')
+ type = 'text'
+ },
+ { col_id = 'description'
+ name = text('Description')
+ type = 'text'
+ } ];
+ IF account_class == 1;
+ columns.push(
+ {col_id = 'lastcost'
+ name = text('Last Cost') #'
+ type = 'text_input'},
+ {col_id = 'partnumber',
+ name = text('Vendor Partnumber') #'
+ type = 'text_input'},
+ {col_id = 'leadtime',
+ name = text('Lead Time') #'
+ type = 'input_text'}
+ );
+ ELSE;
+ columns.push(
+ {col_id = 'sellprice'
+ name = text('Sell Price') #'
+ type = 'input_text'},
+ {col_id = 'validfrom',
+ name = text('Valid From') #'
+ type = 'input_text'},
+ {col_id = 'validto',
+ name = text('Valid To') #'
+ type = 'input_text'},
+ );
+
+ END;
+ columns.push({col_id = 'currency',
+ name = text('Currency'),
+ type = 'text'}
+ );
+ PROCESS dynatable
+ attributes = { id = 'pricematrix' }
+ tbody = { rows = pricematrix };
+ IF pricematrix_pricegroup.size;
+ PROCESS dynatable
+ attributes = { id = 'pricegroup' }
+ tbody = { rows = pricematrix_pricegroup };
+ END;
+?>
+</workbook>
Added: branches/1.3/UI/lib/dynatable.odst
===================================================================
--- branches/1.3/UI/lib/dynatable.odst (rev 0)
+++ branches/1.3/UI/lib/dynatable.odst 2012-05-18 11:28:28 UTC (rev 4718)
@@ -0,0 +1,47 @@
+<?lsmb- BLOCK dynatable;
+
+ROWCOUNT = 1;
+
+IF tbody.rows.size;
+ ROWCOUNT = ROWCOUNT + tbody.rows.size;
+END;
+
+IF tfoot.rows.size;
+ ROWCOUNT = ROWCOUNT + tbody.rows.size;
+END;
+
+-?>
+<worksheet name="<?lsmb attributes.id ?>" rows="<?lsmb ROWCOUNT ?>" columns="<?lsmb columns.size + 1 ?>">
+<format bottom="5" bg_color="lime" bottom_color="magenta">
+<?lsmb IF !hide_header -?>
+ <row>
+ <?lsmb FOREACH COL IN columns;
+ IF COL.type != 'hidden'; -?>
+ <cell text="<?lsmb COL.name ?>" />
+ <?lsmb END; END; ?>
+ </row>
+<?lsmb END -?>
+</format>
+<format align="right">
+<?lsmb FOREACH ROW IN tbody.rows -?>
+ <row>
+ <?lsmb FOREACH COL IN columns -?>
+ <?lsmb IF COL.type != 'hidden'; -?>
+ <cell text="<?lsmb ROW.${COL.col_id} ?>" />
+ <?lsmb END; END -?>
+ </row>
+ <?lsmb END -?>
+<?lsmb- IF tfoot -?>
+ <?lsmb- FOREACH ROW IN tfoot.rows; ?>
+ <row>
+ <?lsmb FOREACH COL IN columns ?>
+ <?lsmb IF COL.type != 'hidden'; -?>
+ <cell text="<?lsmb ROW.${COL.col_id} ?>" />
+
+ <?lsmb END; END ?>
+ </row>
+ <?lsmb END;
+END ?>
+</format>
+</worksheet>
+<?lsmb END ?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.