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

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



Revision: 1761
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1761&view=rev
Author:   tetragon
Date:     2007-10-15 14:54:41 -0700 (Mon, 15 Oct 2007)

Log Message:
-----------
Converting batch printing search forms to templates

Modified Paths:
--------------
    trunk/bin/bp.pl

Added Paths:
-----------
    trunk/UI/bp-search.html

Added: trunk/UI/bp-search.html
===================================================================
--- trunk/UI/bp-search.html	                        (rev 0)
+++ trunk/UI/bp-search.html	2007-10-15 21:54:41 UTC (rev 1761)
@@ -0,0 +1,74 @@
+<?lsmb INCLUDE 'ui-header.html' ?> 
+<?lsmb PROCESS elements.html ?>
+<body>
+<form method="post" action="<?lsmb form.script ?>">
+<table width="100%">
+  <tr><th class="listtop"><?lsmb form.title ?></th></tr>
+  <tr><td> </td></tr>
+  <tr>
+    <td>
+      <table>
+	<tr>
+	  <th align="right"><?lsmb text(label.${form.type}.name) ?></th>
+<?lsmb IF name.type == 'input' ?>
+	  <td colspan="3"><?lsmb PROCESS input element_data=name.data ?></td>
+<?lsmb ELSE ?>
+	  <td colspan="3"><?lsmb PROCESS select element_data=name.data ?></td>
+<?lsmb END ?>
+	</tr>
+<?lsmb FOREACH num IN ['invnumber', 'ordnumber', 'quonumber'];
+  IF label.${form.type}.${num}.defined ?>
+	<tr>
+	  <th align="right" nowrap="nowrap"><?lsmb label.${form.type}.${num}.label ?></th>
+	  <td colspan="3"><?lsmb PROCESS input element_data={size => 20, name => label.${form.type}.${num}.name} ?></td>
+	</tr>
+<?lsmb END; END ?>
+	<tr>
+	  <th align="right" nowrap="nowrap"><?lsmb text('From') ?></th>
+	  <td><?lsmb PROCESS input element_data={class="date", name => "transdatefrom", size => "11", title=> user.dateformat} ?></td>
+	  <th align="right" nowrap="nowrap"><?lsmb text('To') ?></th>
+	  <td><?lsmb PROCESS input element_data={class="date", name => "transdateto", size => "11", title=> user.dateformat} ?></td>
+	</tr>
+<?lsmb IF form.all_years.defined ?>
+        <tr>
+	<th align="right"><?lsmb text('Period') ?></th>
+	<td colspan="3">
+  <?lsmb
+  PROCESS select element_data=form.selectaccountingmonth;
+  PROCESS select element_data=form.selectaccountingyear;
+  PROCESS input element_data={
+    name => 'interval', type => 'radio', value => '0', label => text('Current'),
+    checked => 'checked',
+    };
+  PROCESS input element_data={
+    name => 'interval', type => 'radio', value => '1', label => text('Month'),
+    };
+  PROCESS input element_data={
+    name => 'interval', type => 'radio', value => '3', label => text('Quarter'),
+    };
+  PROCESS input element_data={
+    name => 'interval', type => 'radio', value => '12', label => text('Year'),
+    };
+?>
+	</td>
+      </tr>
+<?lsmb END ?>
+      </table>
+    </td>
+  </tr>
+  <tr>
+    <td><hr size="3" noshade="noshade" /></td>
+  </tr>
+</table>
+
+<br />
+<?lsmb FOREACH hidden IN hiddens.keys;
+	PROCESS input element_data={
+		type => 'hidden',
+		name => hidden,
+		value => hiddens.item(hidden)
+		}; END ?>
+<?lsmb FOREACH button IN buttons; PROCESS button element_data=button; END ?>
+</form>
+</body>
+</html>

Modified: trunk/bin/bp.pl
===================================================================
--- trunk/bin/bp.pl	2007-10-15 20:08:36 UTC (rev 1760)
+++ trunk/bin/bp.pl	2007-10-15 21:54:41 UTC (rev 1761)
@@ -39,6 +39,7 @@
 #======================================================================
 
 use LedgerSMB::BP;
+use LedgerSMB::Template;
 
 1;
 
@@ -56,26 +57,31 @@
     # $locale->text('Quotations')
     # $locale->text('RFQs')
     # $locale->text('Time Cards')
+    my %hiddens;
 
     # setup customer/vendor selection
     BP->get_vc( \%myconfig, \%$form );
 
-    if ( @{ $form->{"all_$form->{vc}"} } ) {
-        $name = "<option>\n";
+    my %name;
+    if ( ref $form->{"all_$form->{vc}"} eq 'ARRAY' ) {
+        $name{type} = 'select';
+        $name{data} = {name => $form->{vc}, options => [{text => '', value => ''}]};
         for ( @{ $form->{"all_$form->{vc}"} } ) {
-            $name .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n|;
+            push @{$name{data}{options}}, {
+                text => $_->{name},
+                value => "$_->{name}--$_->{id}"
+                };
         }
-        $name = qq|<select name=$form->{vc}>$name</select>|;
+    } else {
+        $name{type} = 'input';
+        $name{data} = {name => $form->{vc}, size => 35};
     }
-    else {
-        $name = qq|<input name=$form->{vc} size=35>|;
-    }
 
     # $locale->text('Customer')
     # $locale->text('Vendor')
     # $locale->text('Employee')
 
-    %label = (
+    my %label = (
         invoice           => { title => 'Sales Invoices',  name => 'Customer' },
         packing_list      => { title => 'Packing Lists',   name => 'Customer' },
         pick_list         => { title => 'Pick Lists',      name => 'Customer' },
@@ -89,24 +95,18 @@
         check             => { title => 'Check',           name => 'Vendor' },
     );
 
-    $label{invoice}{invnumber} = qq|
-	<tr>
-	  <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
-	  <td colspan=3><input name=invnumber size=20></td>
-	</tr>
-|;
-    $label{invoice}{ordnumber} = qq|
-	<tr>
-	  <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
-	  <td colspan=3><input name=ordnumber size=20></td>
-	</tr>
-|;
-    $label{sales_quotation}{quonumber} = qq|
-	<tr>
-	  <th align=right nowrap>| . $locale->text('Quotation Number') . qq|</th>
-	  <td colspan=3><input name=quonumber size=20></td>
-	</tr>
-|;
+    $label{invoice}{invnumber} = {
+        label => $locale->text('Invoice Number'),
+        name => 'invnumber',
+        };
+    $label{invoice}{ordnumber} = {
+        label => $locale->text('Order Number'),
+        name => 'ordnumber',
+        };
+    $label{sales_quotation}{quonumber} = {
+        label => $locale->text('Quotation Number'),
+        name => 'quonumber',
+        };
 
     $label{packing_list}{invnumber}      = $label{invoice}{invnumber};
     $label{packing_list}{ordnumber}      = $label{invoice}{ordnumber};
@@ -119,103 +119,61 @@
     $label{request_quotation}{quonumber} = $label{sales_quotation}{quonumber};
 
     # do one call to text
-    $form->{title} =
-        $locale->text('Print') . " "
-      . $locale->text( $label{ $form->{type} }{title} );
+    $form->{title} = $locale->text("Print $label{$form->{type}}{title}");
 
     # accounting years
     if ( @{ $form->{all_years} } ) {
 
         # accounting years
-        $form->{selectaccountingyear} = "<option>\n";
+        $form->{selectaccountingyear} = {
+            name => 'year',
+            options => [{text => '', value => ''}]
+            };
         for ( @{ $form->{all_years} } ) {
-            $form->{selectaccountingyear} .= qq|<option>$_\n|;
+            push @{$form->{selectaccountingyear}{options}}, {
+                text => $_,
+                value => $_
+                };
         }
-        $form->{selectaccountingmonth} = "<option>\n";
+        $form->{selectaccountingmonth} = {
+            name => 'month',
+            options => [{text => '', value => ''}]
+            };
         for ( sort keys %{ $form->{all_month} } ) {
-            $form->{selectaccountingmonth} .=
-              qq|<option value=$_>|
-              . $locale->text( $form->{all_month}{$_} ) . qq|\n|;
+            push @{$form->{selectaccountingmonth}{options}}, {
+                text => $locale->text($form->{all_month}{$_}),
+                value => $_
+                };
         }
-
-        $selectfrom = qq|
-        <tr>
-	<th align=right>| . $locale->text('Period') . qq|</th>
-	<td colspan=3>
-	<select name=month>$form->{selectaccountingmonth}</select>
-	<select name=year>$form->{selectaccountingyear}</select>
-	<input name=interval class=radio type=radio value=0 checked>&nbsp;|
-          . $locale->text('Current') . qq|
-	<input name=interval class=radio type=radio value=1>&nbsp;|
-          . $locale->text('Month') . qq|
-	<input name=interval class=radio type=radio value=3>&nbsp;|
-          . $locale->text('Quarter') . qq|
-	<input name=interval class=radio type=radio value=12>&nbsp;|
-          . $locale->text('Year') . qq|
-	</td>
-      </tr>
-|;
     }
 
-    $form->header;
+    $hiddens{vc} = $form->{vc};
+    $hiddens{type} = $form->{type};
+    $hiddens{title} = $form->{title};
+    $hiddens{sort} = 'transdate';
+    $hiddens{nextsub} = 'list_spool';
+    $hiddens{path} = $form->{path};
+    $hiddens{login} = $form->{login};
+    $hiddens{sessionid} = $form->{sessionid};
 
-    print qq|
-<body>
-
-<form method=post action=$form->{script}>
-|;
-
-    $form->hide_form(qw(vc type title));
-
-    print qq|
-<table width=100%>
-  <tr><th class=listtop>$form->{title}</th></tr>
-  <tr height="5"></tr>
-  <tr>
-    <td>
-      <table>
-	<tr>
-	  <th align=right>| . $locale->text( $label{ $form->{type} }{name} ) . qq|</th>
-	  <td colspan=3>$name</td>
-	</tr>
-	$account
-	$label{$form->{type}}{invnumber}
-	$label{$form->{type}}{ordnumber}
-	$label{$form->{type}}{quonumber}
-	<tr>
-	  <th align=right nowrap>| . $locale->text('From') . qq|</th>
-	  <td><input class="date" name=transdatefrom size=11 title="$myconfig{dateformat}"></td>
-	  <th align=right>| . $locale->text('To') . qq|</th>
-	  <td><input class="date" name=transdateto size=11 title="$myconfig{dateformat}"></td>
-	</tr>
-	$selectfrom
-      </table>
-    </td>
-  </tr>
-  <tr>
-    <td><hr size=3 noshade></td>
-  </tr>
-</table>
-
-<input type=hidden name=sort value=transdate>
-<input type=hidden name=nextsub value=list_spool>
-
-<br>
-<button class="submit" type="submit" name="action" value="continue">|
-      . $locale->text('Continue')
-      . qq|</button>
-|;
-
-    $form->hide_form(qw(path login sessionid));
-
-    print qq|
-
-</form>
-
-</body>
-</html>
-|;
-
+    my @buttons = ({
+        name => 'action',
+        value => 'list_spool',
+        text => $locale->text('Continue'),
+    });
+    my $template = LedgerSMB::Template->new_UI(
+        user => \%myconfig, 
+        locale => $locale, 
+        template => 'bp-search',
+        );
+    $template->render({
+        form => $form,
+        user => \%myconfig,
+        label => \%label,
+        name => \%name,
+        hiddens => \%hiddens,
+        buttons => ..hidden..,
+    });
 }
 
 sub remove {


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