[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[4538] branches/1.3



Revision: 4538
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4538&view=rev
Author:   einhverfr
Date:     2012-03-24 01:41:14 +0000 (Sat, 24 Mar 2012)
Log Message:
-----------
Fixes for pricelist.

Modified Paths:
--------------
    branches/1.3/LedgerSMB/ScriptLib/Common_Search/Part.pm
    branches/1.3/LedgerSMB/ScriptLib/Common_Search.pm
    branches/1.3/LedgerSMB/ScriptLib/Company.pm
    branches/1.3/UI/form-dynatable.html
    branches/1.3/UI/lib/dynatable.html
    branches/1.3/UI/search_results.html
    branches/1.3/css/ledgersmb.css

Modified: branches/1.3/LedgerSMB/ScriptLib/Common_Search/Part.pm
===================================================================
--- branches/1.3/LedgerSMB/ScriptLib/Common_Search/Part.pm	2012-03-23 16:07:00 UTC (rev 4537)
+++ branches/1.3/LedgerSMB/ScriptLib/Common_Search/Part.pm	2012-03-24 01:41:14 UTC (rev 4538)
@@ -47,6 +47,17 @@
    return $COLUMNS;
 }
 
+
+=item row_id
+
+Returns the column_id to use as the row id.
+
+=cut
+
+sub row_id {
+   return 'id';
+}
+
 =item results
 
 Returns a list of results as an array of hashrefs.

Modified: branches/1.3/LedgerSMB/ScriptLib/Common_Search.pm
===================================================================
--- branches/1.3/LedgerSMB/ScriptLib/Common_Search.pm	2012-03-23 16:07:00 UTC (rev 4537)
+++ branches/1.3/LedgerSMB/ScriptLib/Common_Search.pm	2012-03-24 01:41:14 UTC (rev 4538)
@@ -82,8 +82,13 @@
 
 sub render {
     my ($self, $request) = @_;
-    $request->{columns} = $self->columns;
-    $request->{rows} = $self->results;
+    delete $request->{action};
+    my $datahash = { request => $request };
+    $datahash->{columns} = $self->columns;
+    $datahash->{rows} = $self->results;
+    for my $ref(@{$datahash->{rows}}){
+        $ref->{row_id} = $ref->{$self->row_id};
+    }
     my $template = LedgerSMB::Template->new(
        user => $request->{_user},
        locale => $request->{_locale},
@@ -91,7 +96,7 @@
        template => 'search_results',
        format => 'HTML',
     );
-    $template->render($request);
+    $template->render($datahash);
 }
     
 
@@ -109,6 +114,10 @@
 
 Returns a list of results, becomes the rows for the table.
 
+=item row_id
+
+Returns the column name (col_id) to use for the row_id.
+
 =back
 
 =head1 COPYRIGHT

Modified: branches/1.3/LedgerSMB/ScriptLib/Company.pm
===================================================================
--- branches/1.3/LedgerSMB/ScriptLib/Company.pm	2012-03-23 16:07:00 UTC (rev 4537)
+++ branches/1.3/LedgerSMB/ScriptLib/Company.pm	2012-03-24 01:41:14 UTC (rev 4538)
@@ -1040,17 +1040,18 @@
     my ($request) = @_;
     use LedgerSMB::ScriptLib::Common_Search::Part;
     use LedgerSMB::DBObject::Pricelist;
+    my $count = $request->{rowcount_pricematrix};
 
-    my $count = $request->{rowcount_pricematrix};
     my $pricelist = LedgerSMB::DBObject::Pricelist->new({base => $request});
     my @lines;
     my $redirect_to_selection = 0;
+    my $psearch;
 
     # Search and populate
     if (defined $request->{"int_partnumber_tfoot_$count"} 
          or defined $request->{"description_tfoot_$count"})
     {
-        my $psearch = LedgerSMB::ScriptLib::Common_Search::Part->new($request);
+        $psearch = LedgerSMB::ScriptLib::Common_Search::Part->new($request);
         my @parts = $psearch->search(
                    { partnumber => $request->{"int_partnumber_tfoot_$count"},
                     description => $request->{"description_tfoot_$count"}, }
@@ -1093,10 +1094,39 @@
 
     pricelist($request) unless $redirect_to_selection;
 
-    $psearch->render;
+    $request->{search_redirect} = 'pricelist_search_handle';
+    $psearch->render($request);
 }
 
 
+=item pricelist_search_handle
+
+Handles the return from the parts search from the pricelist screen.
+
+=cut
+
+sub pricelist_search_handle {
+    my ($request) = @_;
+    use LedgerSMB::ScriptLib::Common_Search::Part;
+    use LedgerSMB::DBObject::Pricelist;
+
+    my $psearch = LedgerSMB::ScriptLib::Common_Search::Part->new($request);
+    my $part = $psearch->extract;
+
+    my $plist = LedgerSMB::DBObject::Pricelist->new({base => $request });
+    my $row = $request->{rowcount_pricematrix};
+
+    $plist->save([{parts_id => $part->{id},
+                  validfrom => $request->{"validfrom_tfoot_$row"},
+                    validto => $request->{"validto_tfoot_$row"},
+                      price => $request->{"lastcost_tfoot_$row"} ||
+                               $request->{"sellprice_tfoot_$row"},
+                   leadtime => $request->{"leadtime_tfoot_$row"},
+    }]);
+    pricelist($request);
+}
+
+
 =back
 
 =head1 COPYRIGHT

Modified: branches/1.3/UI/form-dynatable.html
===================================================================
--- branches/1.3/UI/form-dynatable.html	2012-03-23 16:07:00 UTC (rev 4537)
+++ branches/1.3/UI/form-dynatable.html	2012-03-24 01:41:14 UTC (rev 4538)
@@ -17,7 +17,7 @@
 <body>
 <form method="post" action="<?lsmb form.script ?>">
 
-<table width="100%">
+<table width="100%" class="dynatable">
   <tr>
     <th class="listtop" colspan="<?lsmb columns.size ?>"><?lsmb form.title ?></th>
   </tr>

Modified: branches/1.3/UI/lib/dynatable.html
===================================================================
--- branches/1.3/UI/lib/dynatable.html	2012-03-23 16:07:00 UTC (rev 4537)
+++ branches/1.3/UI/lib/dynatable.html	2012-03-24 01:41:14 UTC (rev 4538)
@@ -1,5 +1,5 @@
 <?lsmb BLOCK dynatable ?>
-<table id="<?lsmb attributes.id ?>" class="<?lsmb attributes.class ?>">
+<table id="<?lsmb attributes.id ?>" class="dynatable <?lsmb attributes.class ?>">
 <?lsmb- IF !hide_header -?>
 <thead>
    <tr>
@@ -64,7 +64,7 @@
                    END
           ?><a href="<?lsmb HREF ?>"><?lsmb ROW.${COL.col_id} ?></a>
          <?lsmb ELSIF COL.type == 'mirrored';
-         NAME = PFX _ COL.col_id _ '_' _ $ROW.row_id;
+         NAME = PFX _ COL.col_id _ '_' _ ROW.row_id;
          ROW.${COL.col_id} ?>
          <input type="hidden" 
                name="<?lsmb NAME ?>" 
@@ -80,6 +80,7 @@
 <?lsmb- IF tfoot -?>
 <tfoot>
    <?lsmb- FOREACH ROW IN tfoot.rows;
+    SPACECOUNT = 0;
     ROWCOUNT = ROWCOUNT + 1; -?>
    <tr>
      <?lsmb- FOREACH COL IN columns;

Modified: branches/1.3/UI/search_results.html
===================================================================
--- branches/1.3/UI/search_results.html	2012-03-23 16:07:00 UTC (rev 4537)
+++ branches/1.3/UI/search_results.html	2012-03-24 01:41:14 UTC (rev 4538)
@@ -1,5 +1,5 @@
 <?lsmb-
-INCLUDE 'ui-header.html';
+INCLUDE 'ui-header.html' stylesheet = request.stylesheet;
 PROCESS 'elements.html';
 PROCESS 'dynatable.html';
 
@@ -33,8 +33,19 @@
    text = text('Continue')
   class = 'submit'
    type = 'submit'
-}
+  value = request.search_redirect
+};
 
+FOREACH RKEY IN request.keys();
+
+    PROCESS input element_data = {
+           name = RKEY
+           type = "hidden"
+          value = request.$RKEY
+    }; 
+
+END;
+
 -?>
 </form>
 </body>

Modified: branches/1.3/css/ledgersmb.css
===================================================================
--- branches/1.3/css/ledgersmb.css	2012-03-23 16:07:00 UTC (rev 4537)
+++ branches/1.3/css/ledgersmb.css	2012-03-24 01:41:14 UTC (rev 4538)
@@ -136,8 +136,8 @@
 .listheading, thead th { font-size: 10pt; background-color: #004a80; color: white; }
 A.listheading:link, A.listheading:active, A.listheading:visited {
   text-decoration: none; }
-.listrow1 { font-size: 10pt; background-color: #e6e6fa; color: black; vertical-align: top; }
-.listrow0 { font-size: 10pt; background-color: #ffe4e1; color: black; vertical-align: top; }
+.listrow1, table.dynatable tr:nth-child(odd) { font-size: 10pt; background-color: #e6e6fa; color: black; vertical-align: top; }
+.listrow0, table.dynatable tr:nth-child(even) { font-size: 10pt; background-color: #ffe4e1; color: black; vertical-align: top; }
 .listsubtotal { font-size: 10pt; background-color: #5a7d9b; color: white; }
 .listtotal { font-size: 10pt; background-color: #004d99; color: white; }
 

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.