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

SF.net SVN: ledger-smb:[4339] trunk



Revision: 4339
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4339&view=rev
Author:   einhverfr
Date:     2012-02-20 08:42:25 +0000 (Mon, 20 Feb 2012)
Log Message:
-----------
Business unit reporting classes now save

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Business_Unit_Class.pm
    trunk/LedgerSMB/Scripts/business_unit.pm
    trunk/UI/business_units/list_classes.html

Modified: trunk/LedgerSMB/DBObject/Business_Unit_Class.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Business_Unit_Class.pm	2012-02-20 07:22:51 UTC (rev 4338)
+++ trunk/LedgerSMB/DBObject/Business_Unit_Class.pm	2012-02-20 08:42:25 UTC (rev 4339)
@@ -84,6 +84,8 @@
     my @classes = $self->call_procedure(procname => 'business_unit_class__get', 
                                             args => [$id]
     );
+    my $ref = shift @classes;
+    $self->prepare_dbhash($ref);
     return $self->new(shift @classes);
 }
 
@@ -97,7 +99,9 @@
 sub save {
     my ($self) = @_;
     my ($ref) = $self->exec_method({funcname => 'business_unit_class__save'});
-    $self = $self->new($ref);
+    $self->prepare_dbhash($ref);
+    $self = $self->new(%$ref);
+    $self->dbh->commit;
 }   
 
 =item list

Modified: trunk/LedgerSMB/Scripts/business_unit.pm
===================================================================
--- trunk/LedgerSMB/Scripts/business_unit.pm	2012-02-20 07:22:51 UTC (rev 4338)
+++ trunk/LedgerSMB/Scripts/business_unit.pm	2012-02-20 08:42:25 UTC (rev 4339)
@@ -8,7 +8,10 @@
 use LedgerSMB::DBObject::Business_Unit_Class;
 use LedgerSMB::DBObject::Business_Unit;
 use LedgerSMB::Template;
+use Carp;
 
+$Carp::Verbose = 1;
+
 =head1 SYNOPSIS
 
 Workflow routines for LedgerSMB business reporting units
@@ -130,7 +133,7 @@
 
 sub save {
     my ($request) = @_;
-    my $unit = LedgerSMB::DBObject::Business_Unit->new($request);
+    my $unit = LedgerSMB::DBObject::Business_Unit->new(%$request);
     $unit->save;
     edit($request);
 }
@@ -144,7 +147,13 @@
 
 sub save_class {
     my ($request) = @_;
-    my $bu_class = LedgerSMB::DBObject::Business_Unit_Class->new($request);
+    $request->debug({file => '/tmp/search'});
+    for my $key (qw(active non_accounting)){
+        if (!$request->{$key}){
+            $request->{$key} = 0;
+        }
+    }
+    my $bu_class = LedgerSMB::DBObject::Business_Unit_Class->new(%$request);
     $bu_class->save;
     list_classes($request);
 }

Modified: trunk/UI/business_units/list_classes.html
===================================================================
--- trunk/UI/business_units/list_classes.html	2012-02-20 07:22:51 UTC (rev 4338)
+++ trunk/UI/business_units/list_classes.html	2012-02-20 08:42:25 UTC (rev 4339)
@@ -19,12 +19,12 @@
 ?>
 <form action="<?lsmb script ?>" method=POST id="edit-<?lsmb c.id ?>">
 <tr class="row<?lsmb LOOP % 2 ?>">
-<td><?lsmb c.id ?>
+<td>
 <?lsmb PROCESS input element_data = {
     type = "hidden"
    value = c.id
     name = "id"
-} ?></td>
+} ?><?lsmb c.id ?></td>
 <td><?lsmb PROCESS input element_data = {
     type = "text"
    class = "control_code"
@@ -37,8 +37,8 @@
     type = "checkbox"
    value = "1"
    class = "is-active"
-    name = "is_active"
- checked = (c.is_active)? 'CHECKED' : ''
+    name = "active"
+ checked = (c.active)? 'CHECKED' : ''
 } ?>
 </td>
 <td><?lsmb PROCESS input element_data = {
@@ -60,7 +60,7 @@
     type = "submit"
    class = "submit"
     name = "action"
-   value = "save"
+   value = "save_class"
     text = (c.id) ? text('Save') : text('Add')
 };
 PROCESS button element_data = {
@@ -71,6 +71,7 @@
     text = text('Delete')
 } ?>
 </tr>
+</form>
 <?lsmb END ?>
 </table>
 </body>

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